diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0df4cbf --- /dev/null +++ b/.gitignore @@ -0,0 +1,12 @@ +input/other_programs/*.exe +output_exe/*.exe + +input/batch/__pycache__/*.pyc + +output_exe/MoFa4Q_*_Install.exe + +input/other_programs/*.exe +input/other_programs/*.msi + +/.idea + diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..6728999 --- /dev/null +++ b/LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) 2024 Robert Klemm + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) 2024 Robert Klemm + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/README.md b/README.md new file mode 100644 index 0000000..b635f8e --- /dev/null +++ b/README.md @@ -0,0 +1,125 @@ +# ALL CURRENT GPKGS FOR PRESENTATION OF FOSSGIS HAMBURG ARE SAVED UNDER: +https://files.wheregroup.com/s/SXEaPTfSTmKHjmT to avoid to save them directly in GIT-repo + +# QGIS-Install_MoFa4Q +MoFa4Q-Installer has its own Git-Repo (separate from the MoFa4Q Repo) + +MoFa4Q-Installer prepare an executable file, which installs automatically the profile of MoFa4Q on Windows-PC. + +PLEASE NOTE: The installer only works on Windows (not Ubuntu, OSMac)! + +This is the architecture: +![alt diagram](docs/diagram.png) + +The folder output_exe contains an executable file which contains everything necessary to install MoFa4Q. +This final .exe file is created by Inno Script Studio using various files located in the Input folder. The file is quite large because the final exe file contains the QGIS installer itself! + +After installation by the user, the following resources are saved on the computer: +- QGIS application under **C:\Program Files\QGIS 3.xx.xx** +- MoFa4A Application, which contains useful resources (icons, batch files, etc.). +It will be stored: + - C:\Users\[USERR_NAME]\AppData\Local\Programs\ if installed for the only current user + - C:\Program Files\ if installed for all users +- The QGIS profile for MoFa4Q under standard location of profiles **"C:\Users\[USERR_NAME]\AppData\Roaming\QGIS\QGIS3\profiles\profiles\MoFa4Q_{#MyAppCompany}"** + + +## Quick start +Quick start for creating the executable: +1. clone this repo locally (e.g. under C:\devel\mofa4q_public). +The folder is named as [QGIS-Install_MoFa4Q] +2. go to the folder [QGIS-Install_MoFa4Q]\input\profiles\ +3. download the repo of the QGIS profile https://github.com/WhereGroup/qgis_mofa4q_profile in this folder +4. Change the name of the repository folder from 'qgis_mofa4q_profile' to 'mofa4q_public' +5. download QGIS of your choose (at time of writing QGIS LTR Version 3.34.4) +and save the installation file under [QGIS-Install_MoFa4Q]\input\other_programs +6. download demo dop data dop.gpkg from https://files.wheregroup.com/s/SXEaPTfSTmKHjmT +and save it under [QGIS-Install_MoFa4Q]\input\profiles\geopackages\dop +7. to create the installation file you need the program Inno Setup (the used version is innosetup-6.2.1). +Please install from here https://jrsoftware.org/isdl.php. +8. start Inno Script Studio +9. go to the [QGIS-Install_MoFa4Q] folder +10. open the file setup_mofa4q.iss in Inno Script Studio +11. **adjust constants** on the file based on your need (see par. "Configuration setup_mofa4q.iss") + +- folder of the installer = **DEVELDir** (devel) + **DEVEL_QGISInstallMofa4Q** (mofa4q_public) + + Example: C:\devel\mofa4q_public + +- QGIS profile name: = **MyAppName** (MoFa4Q) and **MyAppCompany** (public) + + Example: C:\devel\mofa4q_public\input\profiles\mofa4q_public + +12. click on the button "Compile the current Inno Setup Script" in Inno Script Studio +13. after a while an exe file is created under the folder [QGIS-Install_MoFa4Q]\output_exe +14. distribute the exe file to the PC where you want to install MoFa4Q. Double-click the exe file to install QGIS and MoFa4Q. +15. as an alternative to the exe file, you can use the silent installer (see "Silent installer"). +16. To simulate the use of Synctool (see section Synctool), the last two lines of manifest.txt must be enabled: +``` +qgisSyncDev=dev +qgisSyncDevServer=C:\geopackages +``` +With this configuration, the synctool will look at the local C:\geopackages folder to retrieve new data, instead of looking at a real network server. + + +### Configuration setup_mofa4q.iss +It is possible to customize MoFa4Q, e.g. to define where MoFa4Q should be installed. +The setup is done in the file setup_mofa4q.iss, the configuration file used to generate the exe file. Attention: be careful when changing the configuration, otherwise the program will not work anymore. + +Among the variables the ones worth mentioning are the following: +- **MyAppName** is the name of MoFa4Q application, this constant should be not changed, +because it is used direct in the code (e.g. MoFa4Q.bat) + +- **DEVELDir** where this repo of the installer is saved + +- **DEVEL_QGISInstallMofa4Q** This is the name of the installer repo folder. + +- **QGISVersion** and **QGISFileName**: define the QGIS version. The QGIS's installer must be saved under: + + C:\{#DEVELDir}\{#DEVEL_QGISInstallMofa4Q}\input\other_programs\ + + +NB: **DefaultDirName** defines the folder where the program will be installed + + https://jrsoftware.org/ishelp/index.php?topic=setup_defaultdirname + + +Inno Setup creates under C:\devel\mofa4q_public\output_exe the exe file: +MoFa4Q_public_Install.exe + +Then, I can install on the computer the App MoFa4Q. Double click MoFa4Q_public_Install.exe + +After the installation, we can have a look at what is being installed. + +MoFa4Q program itself (not the profile) which contains batch files and icons is saved at following folder, if the installation is done only for the current user: +C:\Users\[USER_NAME]\AppData\Local\Programs\MoFa4Q + +Otherwise, if the installation is done for all users, it will be saved here: +C:\Users\MoFa4Q + +The profile is under the standard Windows location: +c:\Users\[USER_NAME]\AppData(Roaming)\QGIS\QGIS3\profiles + +### License + Protocols (changelog.txt) + manifest +License and changelog.txt are saved in the profile at the main folder. + +But they are also copied by the installer in the folder: +C:\Users\[USER_NAME]\AppData\Local\Programs\MoFa4Q + +The installer used some its constants of the file setup_mofa4q.iss to generate the **manifest.txt**, which contains informations used by synctool and MoFa4Q + +### Synctool +MoFa4Q used all offline data, even for the background map. A Synctool has been developed to refresh and update the data. When the PC is connected to a network it is possible to check if new data is available and download it. + + +The Synctool is a standalone Python application (file batch/mofa4q_sync.py) which is also installed by the installer. + +To simulate the use of Synctool the last two lines of manifest.txt must be enabled: +``` +qgisSyncDev=dev +qgisSyncDevServer=C:\geopackages +``` +With this configuration, the synctool will look at the local C:\geopackages folder to retrieve new data, instead of looking at a real network server. + +### Silent installer +It is also possible to install MoFa4Q in silent mode (no windows are displayed during the installation). +In addition, SILENT_MoFa4Q_Install_logging.cmd logs information about the installation to a temp file. diff --git a/changelog.md b/changelog.md new file mode 100644 index 0000000..de4fe4a --- /dev/null +++ b/changelog.md @@ -0,0 +1,160 @@ +# Changelog + +All notable changes to this project will be documented in this file. +For each version important additions, changes and removals are listed here. + +The format is inspired from [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) +and the versioning aims to respect [Semantic Versioning](http://semver.org/spec/v2.0.0.html). + +## [v2.1.0] Minor and Feature Release - 2024-01-28 + +### Added +- add MainWindow Function and change icon or title name +- show warning when closing QGIS. Improve popup dialog +- add icon to main window +- add missed improt + +### Changed +- simplify the gpkg_popup.py code +- adjust button dimensions based on resolution +- minor change +- change README.md +- change QGIS projects file +- optimize QGIS3.ini to version 3.34 +- change QGIS Version to 3.34.1 +- improve comments +- move file to the annotation folder +- change zoom to max extent + +### Removed +- remove button function zoom out +- remove comment +- remove unuseful codes + +### Fixed +- fix leftPanel bug on initialization +- fix macros indipendent from process of saving QLR file +- fix position buttons when monitor scale > 125% +- fix position buttons when page resized +- fix rotation for annotations in print +- fix and change main titel and icon path fix +- fix title of the main window +- fix bug log private geopackages + +## [v2.0.2] Fix and Change - 2023-12-29 + +### Added +- add _initCheckGeopackagesLayer and change gpkg_popup.py to dynamic strings +- add new deployment +- add close qgis windows event to close btn of openSynchTool def +- add marco to gpkg_popup +- add alphabetically layers of a new private gpkg file + +### Changed +- change manifest.txt +- change marco path +- change again height els in layer tree +- minor change +- increase width based on text in layer tree + +### Removed +- remove horizontal scrollbar in layer tree +- remove unuseful resources, othe minor changes +- remove red symbol from text annotation +- remove fake geopackage + +### Fixed +- fix gpkgPopup +- fix bugs +- fix marco and qgis project: Save automatic layertree to sequence.yml +- fix gpkgPopup.show mit custom text + +## [v2.0.0] Minor and Feature Release - 2023-11-08 + +### Added +- improvement comments of annotations.py + +### Changed +- change north-arrow to print templates +- improve print and pdf export +- change splash.png +- change projectfile to qgz basename + +### Removed +- remove old qgis ltr version +- remove time info to print templates +- remove unused file +- optimze python code + +### Fixed +- fix bug a4_hoch.qpt +- fix backgroundlayer +- fix problem dim frame of text notation +- fix mFeature.attribute id String of search dialog +- fix height of layer page in left panel +- fix extent of luftbilder layer and optimize view + +## [v1.3.3] Change and Fix - 2023-10-13 + +### Added +- add more variable to manifest file + +### Fixed +- fix path Server_folder + +## [v1.3.2] Change and Fix - 2023-06-22 + +### Changed +- change and update qgis-ltr to 3.22.16 + +### Fixed +- fixed run msi installer + +## [v1.3.1] Change and Fix - 2023-03-24 + +### Added + +### Changed +- change and update to QGIS 3.28.4 + +### Removed + +### Fixed +- bugfix qgis style + +## [v1.3.0] Minor Release - 2022-07-01 + +### Added + +### Changed +- toolbar disable + +### Removed + +### Fixed +- fix bug if info geopackage is corrupt + +## [v1.2.6] Minor Release - 2022-05-31 + +### Added +- set visibility background image +- improve warning for search +- add empty folder to git + +### Changed + +### Removed + +### Fixed + +## [v1.2.5] Minor Release - 2021-11-19 + +### Added +- Improvement plot + +### Changed + +### Removed +- remove warning for some gpkgs + +### Fixed \ No newline at end of file diff --git a/docs/diagram.drawio b/docs/diagram.drawio new file mode 100644 index 0000000..94d4bc2 --- /dev/null +++ b/docs/diagram.drawio @@ -0,0 +1 @@ +7Vttc5s4EP41nrn70AyvfvkYOy/N3HWujdu5uU8eGWTQVCAqhGP3198KhDGgJr7W4FzsjCdGixDSPrvPLis8sGfR5p6jJPzAfEwHluFvBvbNwLLMoe3Cl5RsC8lwOCkEASe+6lQJ5uQ7VkJDSTPi47TWUTBGBUnqQo/FMfZETYY4Z0/1bitG63dNUIBbgrmHaFv6N/FFqKRmuQx54j0mQahuPbZGxYkIlZ3VStIQ+expT2TfDuwZZ0wUR9FmhqlUXqmX4rq7H5zdTYzjWBxywXAunrY0es8WHx6/OM70MXOdd2qUNaKZWrCarNiWGkBpUih2RTYYxpqGIqLQNOEwwZxEWGAO7ZjFcMUUURLE0PRgWlI+3a3bgIaP0lAOkjdIlCt/umKxUMibViW/IVEAy6FkCf+j1EMYvu8AQMynFMVfr9J1AL3beigXhbnAmz2R0ss9ZjBnvoUu6qyjjFTZqFlC9lQh7ipRuIe1M1R2pmws2A1cwSCnXiDxH1CxNagMqVCqqsEz/Jax8sS7NFfiNXQwnWRTnYSjQH5/YCvkfFo8xKlAlAI6alSYZDFw0a1lAqBGUQc+FZx9xTNG2R70K0JpQ9SyBgkKAfe6Vici4vvyNtOnkAg8T5An7/kEZAIyzrLY35nLEYA2jQbStt1C2jQ0UJcWcXSoRx1BzTKRZGKBN/j8QC7BKkGejE4Msml1hPISCS88O4Ah/F7V/dge7iSnA1nH2ucXS83xqAaNYxkaaHoNp6bTkfsRyDrTM3Q/o+F+jm2f3v3ci/vp3G+iY8Z+3W/YVY4jQswXCWcBR9EZ+qHj1KB2DefUPqjLZi8+6Gqzk359cNyRD4L3gafgM/Q+a9wAedKCeGT36XyTl52vVNmfaInpR5YSQZhU3ZIJwaI6Lk31CpZo/fEl+AaWbRjT2zurcN5ETiXaBLJceIW+ZxxfeZRl/iLFfE08nC4gqVqRIONITm4hrUvaGSPyhrdruG+qZngMV504jVzGsiYaZ3VGpXAfS7crLEsj0bjrsnKt45SE7vZKQouBO52xKEHxduDeXD1XPdiJl2/f1+1Wxgsp78kzXuuA4u3F4RtQjptIDh3nFfi7rkB0folTCxxr3E5pe82brK5K8SROMnF2SZNp2HV8T16atbqqDaVYZMkVSc8vMzbNBsMOX0Gs1FWHjgHzHYlRfvdqT80ALcuqvNyTFoiAARgYtLcVIYmDQ61Bh9S+aai4CkAJgugjRAYUBznGedjOsaR4JdRhGe/zi7lSuFGG2Vzb7hQ+oP+ZCakffEHLLFvwaZpjHuXl30/a5C4DAfsToJhZ3vEfOS2wFrhbjJLP7KOcnpp2oc44D3L5MrCX8ZSs8SMuUMoXhDLBVFN2EhxjGauk6o+WRLjDxg7TqL2NaI16tW9dja1hUtgP8Fw1Ye1EbB8xzXOu2+oMoAwmdS3fnKjAxLHfkKQ4iAr9mVLpAMQ6p5BnFSwn8Kx6eT6fNa5dpdOVurSwjmobf1yHpZWvpSzjHlZXVRpvDdTCd2LXBwIdBVi0Bsqh263nF/b/f/z492tsNcdC5CRksBX8EyGWSBUFVDh6iGP2bi4D14Wm3gBNWQ0zHmq3aSynT6KyD3hoffNEBe5ZB2bk/BxRtRB2GwN1TVS659ZjENV1fu98g6dKriqukjnVb3iDooRKBvt0/zD//UJZb4Cy7Ob25UhXnbEmvVLWAS92nJyyCkc/wFW75jbbbWx+lU+DL3Db0Sipqwf6GZMsROQLH0ZBRkX65DEflwlVUU2X90ASM8lcsoEBMCRywT2RzATEBSPGyzQZ1GrpF+J65cQl4aYUJSn2n3Wi0hnKwmTpDI5uJ9jul84OeFHm5HRWkMQzqyg3tF/mPacn3jMaUI93UPfFfJe3L/Kz40kNCNvVpRBd7SJ8wR+//vHNi79F2fcbajp/+XZ4+ZVFfnZUf2HC7HFvR4tKV1s7KijJPEG9n214sjQsw/9S6iMNGRdeJg7eGrhE/tNH/h/H+HILqeSbssTRR41Fa9i6DPi1Bfj9uP2cd3Zeipk00Bt1GLa1C+1qZ+qheDndWDF+4Zw3zjmOofkdmy6YdsY5/4f9pxc5xz0N5zjVy2S/zDnQrH5SXHSvfpht3/4L \ No newline at end of file diff --git a/docs/diagram.png b/docs/diagram.png new file mode 100644 index 0000000..d3664a1 Binary files /dev/null and b/docs/diagram.png differ diff --git a/input/batch/mofa4q.bat b/input/batch/mofa4q.bat new file mode 100644 index 0000000..90db789 --- /dev/null +++ b/input/batch/mofa4q.bat @@ -0,0 +1,36 @@ +@REM Diese Datei startet mithilfe Mofa4Q variablen und startet das Mof4Q-Projekt +:::::::::::::: FIXED PARAMETERS :::::::::::::: +@echo off +set installFolder=c:\PROGRA~1\MoFa4Q +set qgisInstallPath=c:\PROGRA~1\QGIS +set FILE=%installFolder%\manifest.txt +for /f "delims=" %%a in (%FILE%) do set %%a +:::::::::::::: Progress :::::::::::::: + +:::: Check MoFa4Q-Path exist? +IF exist "%FILE%" ( + for /f "delims=" %%a in (%FILE%) do set %%a + goto qgis +) ELSE ( + echo "%FILE% nicht gefunden! || If Errorlevel 1 Goto exit + goto exit +) + +:qgis +::: call QGIS Programm with parameters +::: Check QGIS_DIRECTORY-Path exist? +IF exist "%qgisInstallPath%\bin\%qgisReleaseVersion%.bat" ( + "%qgisInstallPath%\bin\%qgisReleaseVersion%.bat" --skipbadlayers --noversioncheck --profiles-path "%profilePath%" --profile "%profileName%" || If Errorlevel 1 Goto exit + goto mofa4start +) ELSE ( + echo "%qgisInstallPath%\bin\%qgisReleaseVersion%.bat" || If Errorlevel 1 Goto exit + goto exit +) + +:exit +ECHO [ENDE] Prozess beendet. +if %errorlevel%==1 ( + timeout 5 > NUL + pause + exit +) \ No newline at end of file diff --git a/input/batch/mofa4q_sync.bat b/input/batch/mofa4q_sync.bat new file mode 100644 index 0000000..069feff --- /dev/null +++ b/input/batch/mofa4q_sync.bat @@ -0,0 +1,64 @@ +@REM This file starts using Mofa4Q variables and starts the Mof4Q project +:::::::::::::: FIXED PARAMETERS :::::::::::::: +@echo off +setlocal +set installFolder=c:\PROGRA~1\MoFa4Q +set FILE=%installFolder%\manifest.txt +set VAR_COMPANY=wheregroup + +:::::::::::::: Progress :::::::::::::: + +:::: Check MoFa4Q-Path exist? +IF exist "%FILE%" ( + for /f "delims=" %%a in (%FILE%) do set %%a + :::: start cmd min + if not DEFINED IS_MINIMIZED set IS_MINIMIZED=1 && start "" /min "%~dpnx0" %* && exit + goto qgis +) ELSE ( + echo "%FILE% not found! || If Errorlevel 1 Goto exit + goto exit +) + +:qgis +::: set QGIS program path and call o4w_env env +::: check QGIS_DIRECTORY-Path exist? +set QGIS_DIRECTORY="%qgisInstallPath%\bin" +IF exist "%QGIS_DIRECTORY%" ( + call %QGIS_DIRECTORY%\o4w_env.bat + goto mofa4start +) ELSE ( + echo "%FILE% not found! || If Errorlevel 1 Goto exit + goto exit +) + + +:mofa4start +::: set QGIS program path and call o4w_env env +IF DEFINED qgisSyncDev ( + set VAR_COMPANY=%qgisSyncDev% +) +IF NOT DEFINED qgisSyncDevServer ( + set qgisSyncDevServer=%qgisSyncDevServer% +) +IF NOT DEFINED profilePath ( + echo "%profilePath% not found! || If Errorlevel 1 Goto exit + goto exit +) +IF NOT DEFINED installFolder ( + echo "%installFolder% not found! || If Errorlevel 1 Goto exit + goto exit +) + +python "%installFolder%\batch\mofa4q_sync.py" %installFolder% %profilePath%\profiles\%profileName% %VAR_COMPANY% %qgisSyncDevServer% || If Errorlevel 1 Goto exit + +:exit +endlocal +if %errorlevel%==1 ( + ECHO "[ENDE] process finish." + timeout 5 > NUL + pause + exit +) +ELSE ( + exit +) diff --git a/input/batch/mofa4q_sync.py b/input/batch/mofa4q_sync.py new file mode 100644 index 0000000..ed7e2b1 --- /dev/null +++ b/input/batch/mofa4q_sync.py @@ -0,0 +1,471 @@ +# -*- coding: utf-8 -*- +import locale +import os +import shutil +import sys +from abc import abstractmethod +from enum import Enum +from typing import Dict, List, Optional + +from PyQt5.QtCore import (QDateTime, QDir, QFile, Qt, QThread, + pyqtSignal) +from PyQt5.QtGui import QColor, QFont, QIcon, QStandardItem, QStandardItemModel +from PyQt5.QtWidgets import (QApplication, QHBoxLayout, QLabel, QProgressBar, + QPushButton, QSizePolicy, QTableView, QTextEdit, + QVBoxLayout, QWidget) + +from process_exception import ProcessException + + +class DownloadedFile: + """Support class for handling the download""" + name: str + size: float + creationDate: float + updateDate: QDateTime + specialSubFolder: str = None + + def __init__(self, name: str, size: float, updateDate: float) -> None: + self.name = name + self.size = size + self.updateDate = QDateTime.fromSecsSinceEpoch(int(updateDate)) + + +class Status(Enum): + """ Status for the messages """ + NORMAL = "black" + UPDATED = "green" + ERROR = "red" + UPDATED_VIEW = "green" + + +class MoFa4QSync(QWidget): + """Main class showing QWidget with a list of all updatable files""" + DEFAULT_COMPANY = "wheregroup" + SERVER_DEV_FOLDER = "/srv/fake_server" + SERVER_FOLDER_WIN = "\\\\Fake_Server\\download\\data" + INSTALL_PATH = "C:/MoFa4Q" + GPKG_FOLDER_WIN = "C:/MoFa4Q/profiles/MoFa4Q/geopackages/public" + ADDRESS_GEOPACKAGE = "addresses.gpkg" + GEOSEARCH_GEOPACKAGE = "search_objects.gpkg" + AERIALPHOTO_GEOPACKAGE = "dop.gpkg" + TIME_FORMAT = "yyyy-MM-dd HH:mm:ss" + TIMESTAMP_FILE = "_tmstmp.txt" + TITLE = "Synchronisierung - GeoPackages" + INIT_MSG = ("Dieses Programm aktualisiert und lädt alle GeoPackages herunter. " + "\nDateien in rot markiert sind für Luftbilder.") + STOP_MSG = "Der Download wurde gestoppt." + UPDATED_MSG = " ist aktuell" + DOP_MSG = "Luftbilder - ACHTUNG! Download ist aufwändig" + WIDTH = 900 + HEIGHT = 650 + COL_0 = 370 + COL_1 = 100 + COL_2 = 180 + COL_3 = 180 + runThread = None + downloadableList: List[DownloadedFile] = [] + selFiles = [] + + def __init__(self, inputInstallMofa4QPath: Optional[str]=None, inputProfilePath: Optional[str]=None, inputCompany: Optional[str]=None, + inputServerFolder: Optional[str] = None): + super().__init__() + locale.setlocale(locale.LC_ALL, '') + self.installPath = inputInstallMofa4QPath if inputInstallMofa4QPath else self.INSTALL_PATH + self.gpkgFolder = os.path.join(inputProfilePath, 'geopackages\public') if inputProfilePath else self.GPKG_FOLDER_WIN + self.company = inputCompany if inputCompany is not None else self.DEFAULT_COMPANY + self.title = "{0} - {1}".format(self.TITLE, self.company) + self.width = self.WIDTH + self.height = self.HEIGHT + + self.serverFolder = inputServerFolder + # check WIN OS + if os.name == 'nt': + print("Works in windows (Setting for client is used).") + self.isWindows = True + if not self.serverFolder: + self.serverFolder = self.SERVER_FOLDER_WIN + else: + self.isWindows = False + if not self.serverFolder: + self.serverFolder = self.SERVER_DEV_FOLDER + + self.initUI() + + def initUI(self): + + self.setWindowTitle(self.title) + + self.msg = QLabel(self.INIT_MSG, self) + self.msg.setWordWrap(True) + + self.tableView: QTableView = QTableView() + model: QStandardItemModel = QStandardItemModel() + model.setHorizontalHeaderLabels([self.tr('Dateiname'), self.tr('Größe'), self.tr('Letzte Änderung Lokal'), + self.tr('Letzte Änderung Server')]) + self.tableView.setModel(model) + model.itemChanged.connect(self.stateChanged) + self.tableView.setColumnWidth(0, self.COL_0) + self.tableView.setColumnWidth(1, self.COL_1) + self.tableView.setColumnWidth(2, self.COL_2) + self.tableView.setColumnWidth(3, self.COL_3) + + self.textProtocol = QTextEdit() + + self.progressBar = QProgressBar() + + self.btn1 = QPushButton("Download starten", self) + self.btn1.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) + self.btn1.clicked.connect(self.runDownload) + self.btn2 = QPushButton("Stoppen", self) + self.btn2.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) + self.btn2.clicked.connect(self.stopProcess) + self.btn3 = QPushButton("Beenden", self) + self.btn3.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) + self.btn3.clicked.connect(self.closeDialog) + + hLayout = QHBoxLayout() + hLayout.addWidget(self.btn1, 1) + hLayout.addWidget(self.btn2, 0) + hLayout.addWidget(self.btn3, 0) + + layout = QVBoxLayout() + layout.addWidget(self.msg) + layout.addWidget(self.tableView) + layout.addWidget(self.textProtocol) + layout.addWidget(self.progressBar) + layout.addLayout(hLayout) + self.setLayout(layout) + + desktopRect = QApplication.desktop().availableGeometry() + center = desktopRect.center() + + self.setGeometry(int(center.x() - self.width * 0.5), + int(center.y() - self.height * 0.5), self.width, self.height) + self.show() + + try: + self.createList(model) + except FileNotFoundError as e: + self.reportInfo("Keine Verbindung zum Server oder Resource nicht gefunden: {} {}" + .format(self.serverFolder, str(e)), Status.ERROR) + except PermissionError as e: + self.reportInfo("Keine Verbindung zum Server: {} {}".format(self.serverFolder, str(e)), Status.ERROR) + except Exception as e: + self.reportInfo("Unbekannter Fehler: {}".format(str(e)), Status.ERROR) + + def copyLargeFile(self, src, dest, buffer_size=16000): + with open(src, 'rb') as fsrc: + with open(dest, 'wb') as fdest: + # it seems it is not necessary + shutil.copyfileobj(fsrc, fdest, buffer_size) + pass + + def createList(self, model: QStandardItemModel): + rowCount = -1 + dopGpkg: Optional[DownloadedFile] = None + fileEntry: os.DirEntry + for fileEntry in os.scandir(self.serverFolder): + if fileEntry.name.endswith(".gpkg") or fileEntry.name.endswith(".qlr") or fileEntry.name == "sequence_qlr.yml": + dFile = DownloadedFile(fileEntry.name, fileEntry.stat().st_size, fileEntry.stat().st_mtime) + if dFile.name == self.ADDRESS_GEOPACKAGE or dFile.name == self.GEOSEARCH_GEOPACKAGE: + dFile.specialSubFolder = "../search" + if dFile.name == self.AERIALPHOTO_GEOPACKAGE: + dFile.specialSubFolder = "../dop" + dopGpkg = dFile + else: + rowCount += 1 + self.downloadableList.append(dFile) + self.addRow(dFile, rowCount, model) + + if dopGpkg: + rowCount += 1 + self.downloadableList.append(dopGpkg) + self.addRow(dopGpkg, rowCount, model) + + def reportInfo(self, txt: str, status: Status): + """ Sends a info in the protocol """ + if status is Status.NORMAL: + self.textProtocol.setTextColor(QColor("black")) + elif status is Status.UPDATED or status is Status.UPDATED_VIEW: + self.textProtocol.setTextColor(QColor("green")) + elif status is Status.ERROR: + self.textProtocol.setTextColor(QColor("red")) + now = QDateTime.currentDateTime() + if txt != "": + txt = "{} - {}".format(now.toString(self.TIME_FORMAT), txt) + self.textProtocol.append(txt) + self.printLogFile() + + def printLogFile(self): + """ Sends a info in the protocol """ + protocol = self.textProtocol.toPlainText() + logfile_path = os.path.split(self.gpkgFolder)[0] + # print(protocol) + f = open(os.path.join(logfile_path, "protocol.txt"), "w") + f.write(protocol) + f.close() + + def runDownload(self): + self.textProtocol.clear() + self.runThread = RunThread(self.isWindows, self.company, self.selFiles, self.downloadableList, + self.serverFolder, self.TIME_FORMAT, + self.gpkgFolder, self.TIMESTAMP_FILE) + self.runThread.signalStatus.connect(self.reportInfo) + self.runThread.signalBtnEnabled.connect(self.setBtnDisabled) + self.runThread.signalProgressBar.connect(self.setProgressBar) + self.runThread.start() + + def setBtnDisabled(self, isEnabled: bool): + self.btn1.setEnabled(isEnabled) + + def stopProcess(self): + if self.runThread and self.runThread.running: + self.runThread.running = False + self.reportInfo(self.STOP_MSG, Status.ERROR) + + def setProgressBar(self, value: int): + """ Handles progress bar """ + self.progressBar.setValue(value) + + def closeDialog(self): + self.stopProcess() + self.close() + + def addRow(self, dFile: DownloadedFile, rowCount: int, model: QStandardItemModel): + locFile = self.isFileUpdated(dFile) + item1 = QStandardItem(dFile.name + (self.UPDATED_MSG if locFile.get("isUp") else "")) + item1.setCheckable(True) + item1.setEnabled(not locFile.get("isUp")) + item2 = QStandardItem("{:.1f} MB".format(dFile.size / 1000000)) + item3 = QStandardItem(QDateTime.toString( + locFile.get("date"), self.TIME_FORMAT) if locFile.get("date") else "") + item4 = QStandardItem(QDateTime.toString(dFile.updateDate, self.TIME_FORMAT)) + + if dFile.specialSubFolder: + f = QFont() + # f.setItalic(True) + item1.setFont(f) + if dFile.specialSubFolder == "../dop": + item2.setText('ca. {:.1f} GB'.format(round(dFile.size / 100000000) / 10)), # GB + item1.setForeground(QColor("red")) + if locFile.get("isUp") is False: + item1.setText(self.DOP_MSG) + else: + item1.setText("Luftbilder - " + self.UPDATED_MSG) + + model.setItem(rowCount, 0, item1) + model.setItem(rowCount, 1, item2) + model.setItem(rowCount, 2, item3) + model.setItem(rowCount, 3, item4) + + if locFile.get("isUp") is not True and dFile.name != self.AERIALPHOTO_GEOPACKAGE: + item1.setCheckState(Qt.Checked) + else: + item1.setCheckState(Qt.Unchecked) + + def isFileUpdated(self, dFile: DownloadedFile) -> dict[bool, QDateTime]: + """ + Checks if date on the server is more recent than the local geopackage + The method toTime_t() is used: it returns the datetime as the number + of seconds that have passed since 1970-01-01T00:00:00, + Coordinated Universal Time (Qt.UTC). + For special cases (addresses, dop etc.) will be used a special file (timestamp) to make the comparison + """ + locFile: str = os.path.join(self.gpkgFolder, + str(dFile.specialSubFolder or ''), dFile.name) + tmstmpFile: str = os.path.splitext(locFile)[0] + self.TIMESTAMP_FILE + + # special case for qlr + if os.path.splitext(locFile)[1] == '.qlr': + tmstmpFile: str = os.path.splitext(locFile)[0] + '_qlr' + self.TIMESTAMP_FILE + + if QFile.exists(tmstmpFile): + f = open(tmstmpFile, "r") + updatedDate: QDateTime = QDateTime.fromString(f.readline(), self.TIME_FORMAT) + if updatedDate.toString() == "": + return {"isUp": False, "date": None} + else: + return {"isUp": False, "date": None} + + if dFile.updateDate.toTime_t() == updatedDate.toTime_t(): + # print('updatedDate is actual', updatedDate) + return {"isUp": True, "date": updatedDate} + return {"isUp": False, "date": updatedDate} + + def stateChanged(self, item: QStandardItem) -> None: + if item.checkState() == Qt.Checked: + self.selFiles.append(item.row()) + elif item.row() in self.selFiles: + self.selFiles.remove(item.row()) + + +class WorkerThread(QThread): + """ Abstract class for Thread, Definition general methods """ + running: bool = False + + def __init__(self): + QThread.__init__(self) + + @abstractmethod + def run(self): # start() starts run + if self.running is False: + self.running = True + self.doWork() + + @abstractmethod + def stop(self): + self.running = False + + @abstractmethod + def doWork(self): + return True + + @abstractmethod + def cleanUp(self): + pass + + +class RunThread(WorkerThread): + """ Implementation of the class WorkerThread """ + SUCCESS_MSG = "Der Download wurde erfolgreich abgeschlossen." + FAILURE_MSG = "Der Download wurde nicht erfolgreich abgeschlossen." + START_MSG = "Download gestartet. Der Vorgang kann lange dauern" + MB_MSG = "{} Dateien mit insgesamt {:.1f} MB \n" + FILE_DOWNLOAD_MSG = "File {} wird herunterladen..." + COMPLETE_MSG = " Datei {} wurde heruntergeladen" + MAX_PARTIAL_DOWNLOAD = 10 + + signalStatus = pyqtSignal(str, Status) + signalBtnEnabled = pyqtSignal(bool) + signalProgressBar = pyqtSignal(int) + + def __init__(self, isWindows: bool, company: str, selFiles: List[int], downloadableList: List[DownloadedFile], + serverFolder: str, timeFormat: str, folder: str, timestampFile: str): + WorkerThread.__init__(self) + self.SERVER_FOLDER = serverFolder + self.TIME_FORMAT = timeFormat + self.GPKG_FOLDER = folder + self.TIMESTAMP_FILE = timestampFile + self.isWindows = isWindows + self.company = company + self.selFiles: List[int] = selFiles + self.downloadableList: List[DownloadedFile] = downloadableList + # print("self.company", self.company) + + def doWork(self): + try: + print("START......................................") + # remove the folder search or addresses (old implementation of the search) if exists + exDir = QDir(os.path.join(self.GPKG_FOLDER, "search")) + if exDir.exists(): + exDir.removeRecursively() + exDir = QDir(os.path.join(self.GPKG_FOLDER, "addresses")) + if exDir.exists(): + exDir.removeRecursively() + + self.signalProgressBar.emit(0) + self.signalBtnEnabled.emit(False) + totalMb = 0 + selFiles2: List[DownloadedFile] = [] + for rowCount in range(0, len(self.downloadableList)): + if rowCount in self.selFiles: + selFiles2.append(self.downloadableList[rowCount]) + totalMb += self.downloadableList[rowCount].size + + self.downloadSelGpkgs(selFiles2, totalMb) + + self.signalStatus.emit("", Status.NORMAL) + if self.running: + self.signalStatus.emit(self.SUCCESS_MSG, Status.UPDATED) + else: + self.signalStatus.emit(self.FAILURE_MSG, Status.ERROR) + + print("END......................................") + + except ProcessException as e: + self.signalStatus.emit( + "Der Prozess wurde beendet: " + str(e), Status.ERROR) + finally: + self.signalBtnEnabled.emit(True) + self.signalProgressBar.emit(100) + self.running = False + + def downloadSelGpkgs(self, downloadableList: List[DownloadedFile], totalMb: float): + fileCount = len(downloadableList) + actualSize = 0 + self.signalStatus.emit("", Status.NORMAL) + self.signalStatus.emit(self.START_MSG, Status.NORMAL) + self.signalStatus.emit(self.MB_MSG.format( + fileCount, totalMb / 1000000), Status.NORMAL) + dFile: DownloadedFile + for dFile in downloadableList: + if self.running is False: + # stop everything, go out + break + if not dFile.specialSubFolder: + self.getDownloadFile(dFile, actualSize + dFile.size, totalMb, "", "") + else: + self.specialDownload(dFile, actualSize + dFile.size, totalMb) + + actualSize += dFile.size + + def specialDownload(self, dFile: DownloadedFile, actualSize: float, totalMb: float): + self.getDownloadFile(dFile, actualSize, totalMb, "", dFile.specialSubFolder) + + def getDownloadFile(self, dFile: DownloadedFile, newSize: float, totalMb: float, subFolderServer: str, + subFolderLoc: str): + # print(dFile, subFolderServer, subFolderLoc, newSize, totalMb) + self.signalStatus.emit(self.FILE_DOWNLOAD_MSG.format(dFile.name), Status.NORMAL) + localFolder = os.path.join(self.GPKG_FOLDER, subFolderLoc) + if not QDir(localFolder).exists(): + QDir().mkdir(localFolder) + + # time.sleep(4) + locFilePath: str = os.path.join(localFolder, dFile.name) + title: str = "" + + self.downloader(subFolderServer, dFile.name, locFilePath) + + if QFile.exists(locFilePath + ".tmp"): + QFile(locFilePath).remove() + QFile(locFilePath + ".tmp").rename(locFilePath) + # print("newSize", "totalMb", newSize, totalMb, newSize / totalMb * 99) + self.signalProgressBar.emit(int(newSize / totalMb * 99)) + if not title or title == dFile.name: + title = "" + else: + title = "- " + title + " " + if self.running: + self.signalStatus.emit(self.COMPLETE_MSG.format(dFile.name, title), Status.UPDATED_VIEW) + + self.createTimestampFile(dFile.updateDate, locFilePath) + return locFilePath + + def downloader(self, subFolderServer: str, filename: str, dFile: str): + buffer_size = 16 * 16 * 1024 + src = self.SERVER_FOLDER + "/" + subFolderServer + "/" + filename + with open(src, 'rb') as fsrc: + with open(dFile + ".tmp", 'wb') as fdest: + shutil.copyfileobj(fsrc, fdest, buffer_size) + + def createTimestampFile(self, updatedDate: QDateTime, dFile: str): + """ Create an empty text file with last download in the file """ + + fileName: str = os.path.splitext(dFile)[0] + self.TIMESTAMP_FILE + if os.path.splitext(dFile)[1] == '.qlr': # special case for qlr + fileName: str = os.path.splitext(dFile)[0] + '_qlr' + self.TIMESTAMP_FILE + with open(fileName, "w") as timestamp: + timestamp.write(QDateTime.toString(updatedDate, self.TIME_FORMAT)) + + +if __name__ == '__main__': + inputArg1 = sys.argv[1] if sys.argv[1:] else None + inputArg2 = sys.argv[2] if sys.argv[2:] else None + inputArg3 = sys.argv[3] if sys.argv[3:] else None + inputArg4 = sys.argv[4] if sys.argv[4:] else None + app = QApplication(sys.argv) + app.setWindowIcon(QIcon(os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + "/icons/mops_sync_public.ico")) + #print(inputArg1, inputArg2, inputArg3, inputArg4) + ex = MoFa4QSync(inputArg1, inputArg2, inputArg3, inputArg4) + sys.exit(app.exec_()) diff --git a/input/batch/mofa4q_sync_test_in_terminal.bat b/input/batch/mofa4q_sync_test_in_terminal.bat new file mode 100644 index 0000000..a5589d4 --- /dev/null +++ b/input/batch/mofa4q_sync_test_in_terminal.bat @@ -0,0 +1,63 @@ +@REM This file starts using Mofa4Q variables and starts the Mof4Q project +:::::::::::::: FIXED PARAMETERS :::::::::::::: +@echo on +set installFolder=c:\PROGRA~1\MoFa4Q +set FILE=%installFolder%\manifest.txt +set VAR_COMPANY=wheregroup + +:::::::::::::: Progress :::::::::::::: + +:::: Check MoFa4Q-Path exist? +IF exist "%FILE%" ( + for /f "delims=" %%a in (%FILE%) do set %%a + :::: start cmd min + if not DEFINED IS_MINIMIZED set IS_MINIMIZED=1 && start "" /min "%~dpnx0" %* && exit + goto qgis +) ELSE ( + echo "%FILE% not found! || If Errorlevel 1 Goto exit + goto exit +) + +:qgis +::: set QGIS program path and call o4w_env env +::: check QGIS_DIRECTORY-Path exist? +set QGIS_DIRECTORY="%qgisInstallPath%\bin" +IF exist "%QGIS_DIRECTORY%" ( + call %QGIS_DIRECTORY%\o4w_env.bat + goto mofa4start +) ELSE ( + echo "%FILE% not found! || If Errorlevel 1 Goto exit + goto exit +) + + +:mofa4start +::: set QGIS program path and call o4w_env env +IF DEFINED qgisSyncDev ( + set VAR_COMPANY=%qgisSyncDev% +) +IF NOT DEFINED qgisSyncDevServer ( + set qgisSyncDevServer=%qgisSyncDevServer% +) +IF NOT DEFINED profilePath ( + echo "%profilePath% not found! || If Errorlevel 1 Goto exit + goto exit +) +IF NOT DEFINED installFolder ( + echo "%installFolder% not found! || If Errorlevel 1 Goto exit + goto exit +) + +python "%installFolder%\batch\mofa4q_sync.py" %installFolder% %profilePath%\profiles\%profileName% %VAR_COMPANY% %qgisSyncDevServer% || If Errorlevel 1 Goto exit + +:exit +endlocal +if %errorlevel%==1 ( + ECHO "[ENDE] process finish." + timeout 5 > NUL + pause + exit +) +ELSE ( + exit +) diff --git a/input/batch/process_exception.py b/input/batch/process_exception.py new file mode 100644 index 0000000..2c98af0 --- /dev/null +++ b/input/batch/process_exception.py @@ -0,0 +1,3 @@ +class ProcessException(Exception): + """ Base class for exceptions in this module. """ + pass \ No newline at end of file diff --git a/input/batch/uninstall_cleanup_qgisInstall.bat b/input/batch/uninstall_cleanup_qgisInstall.bat new file mode 100644 index 0000000..0a3918d --- /dev/null +++ b/input/batch/uninstall_cleanup_qgisInstall.bat @@ -0,0 +1,27 @@ +@echo OFF +if "%1"=="runas" ( + cd %~dp0 +) else ( + powershell Start -File "cmd '/C %~f0 runas'" -Verb RunAs +) + +set installFolder=c:\PROGRA~1\MoFa4Q +set FILE=%installFolder%\manifest.txt + +for /f "delims=" %%a in (%FILE%) do set %%a + +@GOTO :search + +if _%1_==_payload_ goto :search + +:search + if exist "%qgisInstallPath%" rd /q /s "%qgisInstallPath%" + +goto :finished + +:finished +echo. +echo All Files removed from "%qgisInstallPath%"! +echo. +goto :eof + diff --git a/input/batch/uninstall_icons_all_users.bat b/input/batch/uninstall_icons_all_users.bat new file mode 100644 index 0000000..de41e82 --- /dev/null +++ b/input/batch/uninstall_icons_all_users.bat @@ -0,0 +1,26 @@ +@ECHO ON +@GOTO :search + +if _%1_==_payload_ goto :search + +:getadmin + echo %~nx0: elevating self + set vbs=%temp%\getadmin.vbs + echo Set UAC = CreateObject^("Shell.Application"^) >> "%vbs%" + echo UAC.ShellExecute "%~s0", "search %~sdp0 %*", "", "runas", 1 >> "%vbs%" + "%temp%\getadmin.vbs" + del "%temp%\getadmin.vbs" +goto :eof + +:search +for /f %%a in ('dir /B /AD C:\Users') do ( + if exist "C:\Users\%%a\Desktop\MoFa4Q*.lnk" del /S /F /Q /A "C:\Users\%%a\Desktop\MoFa4Q*.lnk" +) +goto :finished + +:finished +echo. +echo All Icons removed from users desktops! +echo. +goto :eof + diff --git a/input/icons/mops_install_public.ico b/input/icons/mops_install_public.ico new file mode 100644 index 0000000..58a0825 Binary files /dev/null and b/input/icons/mops_install_public.ico differ diff --git a/input/icons/mops_install_public.png b/input/icons/mops_install_public.png new file mode 100644 index 0000000..fece994 Binary files /dev/null and b/input/icons/mops_install_public.png differ diff --git a/input/icons/mops_public.ico b/input/icons/mops_public.ico new file mode 100644 index 0000000..2167b6e Binary files /dev/null and b/input/icons/mops_public.ico differ diff --git a/input/icons/mops_public.png b/input/icons/mops_public.png new file mode 100644 index 0000000..0224d99 Binary files /dev/null and b/input/icons/mops_public.png differ diff --git a/input/icons/mops_sync_public.ico b/input/icons/mops_sync_public.ico new file mode 100644 index 0000000..18856fc Binary files /dev/null and b/input/icons/mops_sync_public.ico differ diff --git a/input/icons/mops_sync_public.png b/input/icons/mops_sync_public.png new file mode 100644 index 0000000..a4e780b Binary files /dev/null and b/input/icons/mops_sync_public.png differ diff --git a/input/other_programs/.gitkeep b/input/other_programs/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/input/profiles/.gitkeep b/input/profiles/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/input/profiles/mofa4q_public b/input/profiles/mofa4q_public new file mode 160000 index 0000000..bd57845 --- /dev/null +++ b/input/profiles/mofa4q_public @@ -0,0 +1 @@ +Subproject commit bd57845e4a575d0239fbfa3c79be918e4fd67c03 diff --git a/output_exe/SILENT_MoFa4Q_Install.cmd b/output_exe/SILENT_MoFa4Q_Install.cmd new file mode 100644 index 0000000..12c3396 --- /dev/null +++ b/output_exe/SILENT_MoFa4Q_Install.cmd @@ -0,0 +1 @@ +MoFa4Q_Install.exe /ALLUSERS /VERYSILENT /SUPPRESSMSGBOXES \ No newline at end of file diff --git a/output_exe/SILENT_MoFa4Q_Install_logging.cmd b/output_exe/SILENT_MoFa4Q_Install_logging.cmd new file mode 100644 index 0000000..ddb6e4b --- /dev/null +++ b/output_exe/SILENT_MoFa4Q_Install_logging.cmd @@ -0,0 +1,2 @@ +if not exist "%TEMP%\MoFa4Q\" mkdir "%TEMP%\MoFa4Q" +MoFa4Q_Install.exe /ALLUSERS /VERYSILENT /SUPPRESSMSGBOXES /FORCECLOSEAPPLICATIONS /LOG=%TEMP%\MoFa4Q\install_MoFa4Q.log \ No newline at end of file diff --git a/output_exe/SILENT_MoFa4Q_Install_logging_currentuser.cmd b/output_exe/SILENT_MoFa4Q_Install_logging_currentuser.cmd new file mode 100644 index 0000000..4900fb7 --- /dev/null +++ b/output_exe/SILENT_MoFa4Q_Install_logging_currentuser.cmd @@ -0,0 +1,2 @@ +if not exist "%TEMP%\MoFa4Q\" mkdir "%TEMP%\MoFa4Q" +MoFa4Q_Install.exe /CURRENTUSER /VERYSILENT /SUPPRESSMSGBOXES /FORCECLOSEAPPLICATIONS /LOG=%TEMP%\MoFa4Q\install_MoFa4Q.log \ No newline at end of file diff --git a/setup_mofa4q.iss b/setup_mofa4q.iss new file mode 100644 index 0000000..dcfef64 --- /dev/null +++ b/setup_mofa4q.iss @@ -0,0 +1,503 @@ +; Script generated by the Inno Script Studio Wizard. +; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! + +; to install for Mofa4q +#define MyAppName "MoFa4Q" +; NOTE: set QGIS profile name +#define MyAppCompany "public" +#define MyAppVersion "2.1.2" +#define MyAppPublisher "WhereGroup GmbH" +#define MyAppURL "http://www.wheregroup.com/" +#define MyAppIconName "MoFa4Q" +#define MyAppSyncIconName "MoFa4Q_Sync" +#define QGISVersion "3.34.4" +#define QGISFileName "QGIS-OSGeo4W-3.34.4-1" +#define DEVELDir "devel" +#define DEVEL_QGISInstallMofa4Q "qgis_mofa4q_installer" +; NOTE: set and managed qgis version to qgis or qgis-ltr +#define QGISReleaseVersion "qgis-ltr" + +[Setup] +; NOTE: The value of AppId uniquely identifies this application. +; Do not use the same AppId value in installers for other applications. +; (To generate a new GUID, click Tools | Generate GUID inside the IDE.) +AppId={{E2ADBEB6-853F-4CB1-B4BB-1F50E09D3154} +AppName={#MyAppName} - {#MyAppCompany} +AppVersion={#MyAppVersion} +AppPublisher={#MyAppPublisher} +AppPublisherURL={#MyAppURL} +AppSupportURL={#MyAppURL} +AppUpdatesURL={#MyAppURL} +;; Note: Not Change Dir Path => it is static +DefaultDirName={autopf64}\{#MyAppName} +DisableDirPage=yes +DisableProgramGroupPage=yes +ShowComponentSizes=no +DisableReadyPage=yes +DefaultGroupName={#MyAppName}_{#MyAppCompany} +OutputDir=C:\{#DEVELDir}\{#DEVEL_QGISInstallMofa4Q}\output_exe +OutputBaseFilename=MoFa4Q_{#MyAppCompany}_Install +SetupIconFile=C:\{#DEVELDir}\{#DEVEL_QGISInstallMofa4Q}\input\icons\mops_install_public.ico +UninstallDisplayIcon=C:\{#DEVELDir}\{#DEVEL_QGISInstallMofa4Q}\input\icons\mops_install_public.ico +UninstallDisplayName={#MyAppName} +VersionInfoVersion={#MyAppVersion} +LicenseFile=C:\{#DEVELDir}\{#DEVEL_QGISInstallMofa4Q}\LICENSE +InfoAfterFile=C:\{#DEVELDir}\{#DEVEL_QGISInstallMofa4Q}\changelog.md +WizardStyle=modern + +; Set default Disk Space require QGIS(~3GB) + Mofa4q(~2GB) +ExtraDiskSpaceRequired=5000000000 + +; "ArchitecturesAllowed=x64" specifies that Setup cannot run on +; anything but x64. +ArchitecturesAllowed=x64 + +; Best compression settings in Inno Setup compiler +Compression=none +;Compression=lzma2/fast +SolidCompression=yes +LZMAUseSeparateProcess=yes + +; Admin privileges +PrivilegesRequiredOverridesAllowed=commandline dialog +; admin | lowest +PrivilegesRequired=lowest + +[Languages] +Name: "english"; MessagesFile: "compiler:Default.isl" +Name: "german"; MessagesFile: "compiler:Languages\German.isl" + +[CustomMessages] +english.UninstallQgisProfile=English Would you also like to completely delete the local QGIS profile %1 ? +german.UninstallQgisProfile=German M�chten Sie komplett das lokale QGIS Profile von %1 l�schen? +english.UninstallQgis=English Would you also like to completely uninstall the QGIS program with version %1 ? +german.UninstallQgis=German M�chten Sie komplett das QGIS-Programm mit der Version von %1 deinstallieren? +english.ErrorUninstallCleanupQgisInstall=Failed running uninstall_cleanup_qgisInstall.bat file +german.ErrorUninstallCleanupQgisInstall=Fehler beim Ausf�hren der Datei uninstall_cleanup_qgisInstall.bat +english.ErrorOtherRunInstaller=Other installer failed to run! +german.ErrorOtherRunInstaller=Anderes Installationsprogramm konnte nicht ausgef�hrt werden! + +[Tasks] +; checkbox for creating desktop link + +[Files] +Source: "C:\{#DEVELDir}\{#DEVEL_QGISInstallMofa4Q}\input\other_programs\{#QGISFileName}.msi"; \ + Excludes: "*.~*,*__~*,*.git*,*.vscode*,*.idea*"; \ + DestDir: "{app}\other_programs"; \ + AfterInstall: CheckAndInstallQgis; \ + Flags: comparetimestamp; +Source: "C:\{#DEVELDir}\{#DEVEL_QGISInstallMofa4Q}\input\profiles\{#MyAppName}_{#MyAppCompany}\*"; \ + Excludes: "*.~*,*__~*,*.git*,*.vscode*,*.idea*,*__pycache__*,*annotations.yaml*"; \ + DestDir: "{userappdata}\QGIS\QGIS3\profiles\{#MyAppName}_{#MyAppCompany}"; \ + Flags: createallsubdirs recursesubdirs +Source: "C:\{#DEVELDir}\{#DEVEL_QGISInstallMofa4Q}\input\icons\*.*"; \ + Excludes: "*.~*,*__~*,*.git*,*.vscode*,*.idea*"; \ + DestDir: "{app}\icons"; \ + Flags: comparetimestamp; +Source: "C:\{#DEVELDir}\{#DEVEL_QGISInstallMofa4Q}\input\batch\*.*"; \ + Excludes: "*.~*,*__~*,*.git*,*.vscode*,*.idea*,*__pycache__*"; \ + DestDir: "{app}\batch"; +Source: "C:\{#DEVELDir}\{#DEVEL_QGISInstallMofa4Q}\input\batch\uninstall_cleanup_qgisInstall.bat"; \ + DestDir: "{app}\batch"; \ + AfterInstall: ReplaceBatfile('{app}\batch','uninstall_cleanup_qgisInstall.bat'); +Source: "C:\{#DEVELDir}\{#DEVEL_QGISInstallMofa4Q}\input\batch\mofa4q.bat"; \ + DestDir: "{app}\batch"; \ + AfterInstall: ReplaceBatfile('{app}\batch','mofa4q.bat'); +Source: "C:\{#DEVELDir}\{#DEVEL_QGISInstallMofa4Q}\input\batch\mofa4q_sync.bat"; \ + DestDir: "{app}\batch"; \ + AfterInstall: ReplaceBatfile('{app}\batch','mofa4q_sync.bat'); +Source: "C:\{#DEVELDir}\{#DEVEL_QGISInstallMofa4Q}\input\batch\mofa4q_sync_test_in_terminal.bat"; \ + DestDir: "{app}\batch"; \ + AfterInstall: ReplaceBatfile('{app}\batch','mofa4q_sync_test_in_terminal.bat'); +Source: "C:\{#DEVELDir}\{#DEVEL_QGISInstallMofa4Q}\LICENSE"; \ + DestDir: "{app}"; \ + Flags: comparetimestamp; +Source: "C:\{#DEVELDir}\{#DEVEL_QGISInstallMofa4Q}\changelog.md"; \ + DestDir: "{app}"; \ + DestName: "changelog.txt"; \ + Flags: comparetimestamp; + +; NOTE: Don't use "Flags: ignoreversion" on any shared system files + +[Icons] +; create desktop link +; we create desktop link for all users per [code] + +; create start menu link +Name: "{autostartmenu}\{#MyAppName}\{#MyAppIconName}_{#MyAppCompany}"; \ + Filename: "{app}\batch\mofa4q.bat"; \ + IconFilename: {app}\icons\mops_public.ico; \ + Comment: "Startet die QGIS mit dem Profil {#MyAppName}"; \ + WorkingDir: "{app}\batch"; \ + Flags: foldershortcut; +Name: "{autostartmenu}\{#MyAppName}\{#MyAppSyncIconName}_{#MyAppCompany}"; \ + Filename: "{app}\batch\mofa4q_sync.bat"; \ + IconFilename: {app}\icons\mops_sync_public.ico; \ + Comment: "Startet die Anwendung Mofa4q-Sync"; \ + WorkingDir: "{app}\batch"; \ + Flags: foldershortcut runminimized; + +[Run] + +[UninstallDelete] +;This works if it is installed in custom location +Type: files; Name: "{app}\*"; +Type: filesandordirs; Name: "{app}" + +[Code] +var + Label1: TLabel; + +function frmDomainReg_CreatePage(PreviousPageId: Integer): Integer; +var + Page: TWizardPage; + begin + Page := CreateCustomPage( + PreviousPageId, + 'MoFa4Q Installer', + 'Installer wird QGIS und MoFa4Q-Profil' + ); + Label1 := TLabel.Create(Page); + with Label1 do + begin + Parent := Page.Surface; + Caption := 'Mit dem Installer wird das QGIS und das MoFa4Q-Profil installiert.'; + Left := ScaleX(0); + Top := ScaleY(0); + Width := ScaleX(400); + Height := ScaleY(17); + end; + end; + +procedure CurStepChanged(CurStep: TSetupStep); +var + UsersPath: string; + CommonDesktopShortPath: string; + DesktopPath: string; + ShortcutPath_1: string; + ShortcutPath_2: string; + FindRec: TFindRec; + ShortcutsCount: Integer; +begin + { Once the files are installed } + if CurStep = ssPostInstall then + begin + Log('Creating shortcuts for all users'); + { Assuming the common users root (typically C:\Users) is two level up } + { from the current user desktop folder } + UsersPath := + AddBackslash(ExtractFilePath(RemoveBackslash(ExtractFilePath( + RemoveBackslash(ExpandConstant('{userdesktop}')))))); + Log(Format('Users root [%s]', [UsersPath])); + CommonDesktopShortPath := GetShortName(ExpandConstant('{commondesktop}')); + Log(Format('Common desktop [%s]', [CommonDesktopShortPath])); + + { check all users if exits icons and delete} + { Iterate all users } + ShortcutsCount := 0 + if FindFirst(UsersPath + '*', FindRec) then + begin + try + repeat + { Just directories, not interested in files } + if FindRec.Attributes and FILE_ATTRIBUTE_DIRECTORY <> 0 then + begin + { Check if there is a Desktop subfolder } + Log('Start: check all users if exits icons and delete'); + DesktopPath := UsersPath + FindRec.Name + '\Desktop'; + if DirExists(DesktopPath) then + begin + if CompareText( + CommonDesktopShortPath, GetShortName(DesktopPath)) = 0 then + begin + Log(Format('Skipping common desktop [%s]', [DesktopPath])); + end + else + begin + ShortcutPath_1 := DesktopPath + '\{#MyAppIconName}_{#MyAppCompany}.lnk'; + ShortcutPath_2 := DesktopPath + '\{#MyAppSyncIconName}_{#MyAppCompany}.lnk'; + Log(Format( + 'Found desktop folder for user [%s], creating shortcut [%s]', [ + FindRec.Name, ShortcutPath_1])); + Log(Format( + 'Found desktop folder for user [%s], creating shortcut [%s]', [ + FindRec.Name, ShortcutPath_2])); + try + DeleteFile(ExpandConstant(ShortcutPath_1)); + DeleteFile(ExpandConstant(ShortcutPath_2)); + Log(Format('Shortcut [%s] delete', [ShortcutPath_1])); + Log(Format('Shortcut [%s] delete', [ShortcutPath_2])); + Inc(ShortcutsCount); + except + Log(Format('Failed to delete shortcut: %s', [GetExceptionMessage])); + end; + end; + end; + end; + until not FindNext(FindRec); + finally + FindClose(FindRec); + end; + + Log(Format('%d shortcuts created', [ShortcutsCount])); + end + else + begin + Log('Error: check all users if exits icons and delete'); + Log(Format('Error listing [%s]', [UsersPath])); + end; + + { create icon for common or user desktop } + log('create icon for common or user desktop'); + if isAdmin then + begin + CommonDesktopShortPath := GetShortName(ExpandConstant('{commondesktop}')); + Log(Format('Common desktop [%s]', [CommonDesktopShortPath])); + + DesktopPath := CommonDesktopShortPath; + ShortcutPath_1 := DesktopPath + '\{#MyAppIconName}_{#MyAppCompany}.lnk'; + ShortcutPath_2 := DesktopPath + '\{#MyAppSyncIconName}_{#MyAppCompany}.lnk'; + + DeleteFile(ExpandConstant(ShortcutPath_1)); + DeleteFile(ExpandConstant(ShortcutPath_2)); + + try + ShortcutPath_1 := CreateShellLink( + ShortcutPath_1, '', ExpandConstant('{app}\batch\mofa4q.bat'), '', + ExpandConstant('{app}'), ExpandConstant('{app}\icons\mops_public.ico'), 0, SW_SHOWNORMAL); + ShortcutPath_2 := CreateShellLink( + ShortcutPath_2, '', ExpandConstant('{app}\batch\mofa4q_sync.bat'), '', + ExpandConstant('{app}'), ExpandConstant('{app}\icons\mops_sync_public.ico'), 0, SW_SHOWNORMAL); + Log(Format('Shortcut [%s] created', [ShortcutPath_1])); + Log(Format('Shortcut [%s] created', [ShortcutPath_2])); + Inc(ShortcutsCount); + except + Log(Format('Failed to create shortcut: %s', [GetExceptionMessage])); + end; + end + else + begin + DesktopPath := GetShortName(ExpandConstant('{userdesktop}')); + ShortcutPath_1 := DesktopPath + '\{#MyAppIconName}_{#MyAppCompany}.lnk'; + ShortcutPath_2 := DesktopPath + '\{#MyAppSyncIconName}_{#MyAppCompany}.lnk'; + + Log(Format('User desktop [%s]', [DesktopPath])); + try + ShortcutPath_1 := CreateShellLink( + ShortcutPath_1, '', ExpandConstant('{app}\batch\mofa4q.bat'), '', + ExpandConstant('{app}'), ExpandConstant('{app}\icons\mops_public.ico'), 0, SW_SHOWNORMAL); + ShortcutPath_2 := CreateShellLink( + ShortcutPath_2, '', ExpandConstant('{app}\batch\mofa4q_sync.bat'), '', + ExpandConstant('{app}'), ExpandConstant('{app}\icons\mops_sync_public.ico'), 0, SW_SHOWNORMAL); + Log(Format('Shortcut [%s] created', [ShortcutPath_1])); + Log(Format('Shortcut [%s] created', [ShortcutPath_2])); + except + Log(Format('Failed to create shortcut: %s', [GetExceptionMessage])); + end; + end; + end; +end; + +procedure ExitProcess(exitCode:integer); + external 'ExitProcess@kernel32.dll stdcall'; + +function FileReplaceString(const FileName, SearchString, ReplaceString: string):boolean; +var + MyFile : TStrings; + MyText : string; +begin + MyFile := TStringList.Create; + + try + result := true; + + try + MyFile.LoadFromFile(FileName); + MyText := MyFile.Text; + + { Only save if text has been changed. } + if StringChangeEx(MyText, SearchString, ReplaceString, True) > 0 then + begin; + MyFile.Text := MyText; + MyFile.SaveToFile(FileName); + end; + except + result := false; + end; + finally + MyFile.Free; + end; +end; + +procedure ReplaceBatfile(DestDir: String; FileName: String); +var + ResultCode: Integer; +begin + ResultCode := 1; + begin + if CompareStr(ExpandConstant('{app}'),'C:\Program Files\{#MyAppName}') = 0 then begin + Log('replace Path of Batchfiles: CompareStr is same'); + end + else begin + if FileExists(ExpandConstant(DestDir + '\' + FileName)) then begin + Log('replace Path of Batchfiles: File found: '+DestDir+'\'+FileName); + FileReplaceString(ExpandConstant(DestDir + '\' + FileName), 'installFolder=c:\PROGRA~1\MoFa4Q', 'installFolder='+ExpandConstant('{app}')); + end + end + end +end; + +procedure InstallQgis; +var + ResultCode: Integer; +begin + if ShellExec('', 'msiexec.exe', + ExpandConstant('/I "{app}\other_programs\{#QGISFileName}.msi" /passive MSIFASTINSTALL=3 INSTALLDESKTOPSHORTCUTS=0 OPTIONS="noAutoStart=true"'), + '', SW_SHOWNORMAL, ewWaitUntilTerminated, ResultCode) + then + begin + Log('{#QGISFileName}.msi has been installed or is already installed. Continue with MoFa4Q!'); + end + else begin + SuppressibleMsgBox(ExpandConstant('{cm:ErrorOtherRunInstaller}') + #13#10 + + SysErrorMessage(ResultCode), mbError, MB_OK, MB_OK); + ExitProcess(0); + end; +end; + +procedure CheckAndInstallQgis; +begin + DeleteFile(ExpandConstant('{app}\manifest.txt')); + if FileExists(ExpandConstant('{app}\manifest.txt')) then begin + Log('CheckAndInstallQgis: delete old manifest File!'); + DeleteFile(ExpandConstant('{app}\manifest.txt')) + end; + begin + SaveStringToFile(ExpandConstant('{app}\manifest.txt'), 'appVersion='+'{#MyAppVersion}'+ #13#10, True); + SaveStringToFile(ExpandConstant('{app}\manifest.txt'), 'appPublisher='+'{#MyAppPublisher}'+ #13#10, True); + SaveStringToFile(ExpandConstant('{app}\manifest.txt'), 'supportQGIS='+'{#QGISVersion}'+ #13#10, True); + SaveStringToFile(ExpandConstant('{app}\manifest.txt'), 'qgisReleaseVersion='+'{#QGISReleaseVersion}'+ #13#10, True); + SaveStringToFile(ExpandConstant('{app}\manifest.txt'), 'qgisInstallPath='+'C:\PROGRA~1\QGIS {#QGISVersion}'+ #13#10, True); + SaveStringToFile(ExpandConstant('{app}\manifest.txt'), 'profilePath='+ ExpandConstant('{userappdata}\QGIS\QGIS3')+ #13#10, True); + SaveStringToFile(ExpandConstant('{app}\manifest.txt'), 'profileName='+'{#MyAppName}_{#MyAppCompany}'+ #13#10, True); + SaveStringToFile(ExpandConstant('{app}\manifest.txt'), '##qgisSyncDev='+'dev'+ #13#10, True); + SaveStringToFile(ExpandConstant('{app}\manifest.txt'), '##qgisSyncDevServer='+'C:\geopackages', True); + end; + begin + Log('CheckAndInstallQgis: Check QGIS {#QGISVersion}!'); + if (DirExists('C:\Program Files\QGIS {#QGISVersion}\lib') = false) then + begin + Log('C:\Program Files\QGIS {#QGISVersion}\lib not exits!'); + InstallQgis; + end + end; +end; + +procedure UninstallQgis; +var + ResultCode: Integer; +begin + if ShellExec('', 'msiexec.exe', + ExpandConstant('/uninstall "{app}\other_programs\{#QGISFileName}.msi" MSIFASTINSTALL=3 /q /passive'), + '', SW_SHOWNORMAL, ewWaitUntilTerminated, ResultCode) + then + begin + Log('{#QGISFileName}.msi is uninstall. Bye Bye!'); + end + else begin + SuppressibleMsgBox(ExpandConstant('{cm:ErrorOtherRunInstaller}') + #13#10 + \ + SysErrorMessage(ResultCode), mbError, MB_OK, MB_OK); + ExitProcess(0); + end; + + if Exec(ExpandConstant('{app}\batch\uninstall_cleanup_qgisInstall.bat'), '', '', \ + SW_HIDE, ewWaitUntilTerminated, ResultCode) + then + begin + Log('Succeeded running uninstall_cleanup_qgisInstall batch file'); + end + else begin + SuppressibleMsgBox(ExpandConstant('{cm:ErrorUninstallCleanupQgisInstall}') + #13#10 + \ + SysErrorMessage(ResultCode), mbError, MB_OK, MB_OK); + ExitProcess(0); + end; + +end; + +procedure UninstallShortcutAllUsers; +var + ResultCode: Integer; +begin + if Exec(ExpandConstant('{app}\batch\uninstall_icons_all_users.bat'), '', '', \ + SW_HIDE, ewWaitUntilTerminated, ResultCode) + then + begin + Log('Succeeded running uninstall_icons_all_users batch file'); + end + else begin + SuppressibleMsgBox('Failed running uninstall_icons_all_users.bat file' + #13#10 + \ + SysErrorMessage(ResultCode), mbError, MB_OK, MB_OK); + ExitProcess(0); + end; +end; + +procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep); +var + DesktopPath: string; + ShortcutPath_1: string; + ShortcutPath_2: string; + DeleteQGISProfilePath: integer; + DeleteQGISPath: integer; + DeleteProfileName: string; +begin + Log('CurUninstallStepChanged + ' + IntToStr(Integer(CurUninstallStep))); + case CurUninstallStep of + usUninstall: + begin + // Ask the user a Yes/No question, defaulting to YES + DeleteQGISProfilePath := MsgBox(ExpandConstant('{cm:UninstallQgisProfile, {#MyAppName}_{#MyAppCompany}}'), mbConfirmation, MB_YESNO or MB_DEFBUTTON1) + DeleteQGISPath := MsgBox(ExpandConstant('{cm:UninstallQgis, {#QGISVersion}}'), mbConfirmation, MB_YESNO or MB_DEFBUTTON1) + + if DeleteQGISProfilePath = IDYES then + //this is the msg that will display after uninstall,change is as you prefer + begin + DeleteProfileName := '{#MyAppName}_{#MyAppCompany}'; + Log('delete QGIS-Profil '+DeleteProfileName); + DelTree(ExpandConstant('{userappdata}\QGIS\QGIS3\profiles\'+DeleteProfileName), True, True, True); + end; + + if DeleteQGISPath = IDYES then + //this is the msg that will display after uninstall,change is as you prefer + begin + if (DirExists('C:\Program Files\QGIS {#QGISVersion}\lib') = true) then + begin + Log('Uninstall QGIS MSI-File'); + UninstallQgis + end; + end; + + DesktopPath := 'C:\Users\Public\Desktop'; + if DirExists(DesktopPath) then + begin + Log('find DesktopPath:'+ DesktopPath); + ShortcutPath_1 := DesktopPath + '\{#MyAppIconName}_{#MyAppCompany}.lnk'; + ShortcutPath_2 := DesktopPath + '\{#MyAppSyncIconName}_{#MyAppCompany}.lnk'; + DeleteFile(ExpandConstant(ShortcutPath_1)); + DeleteFile(ExpandConstant(ShortcutPath_2)); + Log('delete Shortcut:'+ ShortcutPath_1); + Log('delete Shortcut:'+ ShortcutPath_2); + end; + begin + Log('Start uninstall Shortcut all users'); + UninstallShortcutAllUsers + end; + end; + end; +end; + + +procedure InitializeWizard(); +begin +{this page will come after welcome page} +frmDomainReg_CreatePage(wpWelcome); +end;