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

57 | 58 |

59 | 60 | ## OS Support 61 | 62 | Currently supported images: 63 | 64 | | Operating system | URL | 65 | | ---------------- | --- | 66 | | Debian (arm64) | https://cdimage.debian.org/debian-cd/current/arm64/iso-cd/ | 67 | | Debian (amd64) | https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/ | 68 | | CentOS 8 | http://ftp.halifax.rwth-aachen.de/centos/8/isos/ | 69 | | Rocky Linux 8 | https://download.rockylinux.org/pub/rocky/8/isos/ | 70 | | Grml | https://download.grml.org/ | 71 | | Ubuntu (18.04, 20.04, 21.04) | https://ftp.halifax.rwth-aachen.de/ubuntu-releases/ | 72 | | Manjaro (XFCE, KDE) | https://manjaro.org/downloads/official/ | 73 | | Finnix 123 | https://www.finnix.org/releases/123/ | 74 | 75 | With the option `add-url` you have the possibility to add new ISO sources. 76 | 77 | ## Install Ventoy Updater 78 | 79 | ```bash 80 | $ pip3 install ventoyu 81 | ``` 82 | 83 | **Note:** You may want to install with option `--user`. 84 | 85 | ## How to 86 | 87 | ### Install new images 88 | 89 | ```bash 90 | $ sudo ventoyu install 91 | ``` 92 | 93 | ### Add a new ISO download source 94 | 95 | **Tip:** Before add a new URL, check it with `check-url`. 96 | 97 | ```bash 98 | $ sudo ventoyu add-url --url 99 | ``` 100 | 101 | ## Install or update Ventoy 102 | 103 | ```bash 104 | $ sudo ventoyu --device /dev/sdX config install 105 | ``` 106 | 107 | This function downloads the latest Ventoy release. 108 | 109 | **Tip:** You have the possibility to open the Ventoy GUI installer with `--gui`. 110 | 111 | ### Get help 112 | 113 | For more information type `ventoyu --help`. 114 | -------------------------------------------------------------------------------- /bin/ventoyu: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Author: Marcel-Brian Wilkowsky (mawigh) 3 | 4 | import argparse; 5 | import os; 6 | import re; 7 | import sys; 8 | import json; 9 | import time; 10 | import threading; 11 | import queue; 12 | import shutil; 13 | import requests; 14 | import ventoyl; 15 | from bs4 import BeautifulSoup; 16 | from itertools import chain; 17 | from difflib import SequenceMatcher; 18 | 19 | def load (msg:str): 20 | characters = "/-\|"; 21 | for char in characters: 22 | sys.stdout.write("\r"+msg+"... "+char); 23 | time.sleep(.1); 24 | sys.stdout.flush(); 25 | 26 | def hr_filesize (size): 27 | units = ["B", "KiB", "MiB", "GiB", "TiB", "PiB"]; 28 | for unit in units: 29 | if size < 1024.0 or unit == "PiB": 30 | break; 31 | size /= 1024.0 32 | return f"{size:.0f} {unit}"; 33 | 34 | def download_file (mount_dir, iso_name, url): 35 | 36 | print("Downloading " + bchar.HEADER + str(iso_name) + bchar.ENDC + " from " + bchar.OKBLUE + str(url) + bchar.ENDC + " ..."); 37 | download_request = requests.get(url + str(iso_name), stream=True, allow_redirects=True); 38 | start = time.process_time(); 39 | download_length = download_request.headers.get("content-length"); 40 | dl = 0; 41 | final_location = str(mount_dir) + "/" + str(iso_name); 42 | downloaded_file = open(final_location, "wb"); 43 | 44 | for chunk in download_request.iter_content(1024): 45 | dl += len(chunk); 46 | downloaded_file.write(chunk); 47 | done = int(50 * dl / int(download_length)); 48 | progress = "=" * done; 49 | half = " " * (50-done); 50 | timep = dl//(time.process_time() - start); 51 | timep = hr_filesize(timep/8); 52 | sys.stdout.write("\r"+bchar.OKCYAN+"["+bchar.ENDC + bchar.OKBLUE + str(progress) + str(half) +bchar.OKCYAN+"]"+bchar.ENDC+" "+str(timep)); 53 | 54 | print("\nTime Elapsed: " + str(time.process_time() - start) + "s\n"); 55 | downloaded_file.close(); 56 | 57 | class bchar: 58 | HEADER = '\033[95m' 59 | OKBLUE = '\033[94m' 60 | OKCYAN = '\033[96m' 61 | OKGREEN = '\x1b[32m' 62 | WARNING = '\033[93m' 63 | FAIL = '\033[91m' 64 | ENDC = '\033[0m' 65 | BOLD = '\033[1m' 66 | UNDERLINE = '\033[4m' 67 | 68 | def main (): 69 | 70 | global etcdir; 71 | etcdir = os.path.abspath(os.path.join(os.path.dirname(ventoyl.__file__), "etc")); 72 | parser = argparse.ArgumentParser(prog="Ventoy Updater", description="Update ISO image found on a ventoy device"); 73 | parser.add_argument("--device", help="explicit specifiy a Ventoy device (e.g. sda1)"); 74 | parser.add_argument("-v", "--verbose", dest="v", action="store_true", help="enable verbose mode"); 75 | parser.add_argument("-l", "--no-logo", dest="l", action="store_true", help="disable Ventoy ASCII logo"); 76 | parser.add_argument("-V", "--version", action="version", version="%(prog)s 0.4"); 77 | 78 | subparser = parser.add_subparsers(dest="command"); 79 | 80 | sinstall = subparser.add_parser("install", help="install new ISO images"); 81 | sinstall.add_argument("-m", "--no-umount", dest="m", action="store_true", help="DO NOT umount Ventoy device after install"); 82 | sinstall.add_argument("-o", "--os", dest="short_name", help="short name of the OS you want to install (e.g. debian/manjaro)"); 83 | sinstall.add_argument("-f", "--file", dest="file", help="copy specified ISO file to your Ventoy device (just a cp)"); 84 | 85 | sremove = subparser.add_parser("remove", help="remove an installed ISO image from your Ventoy device"); 86 | 87 | scheckurl = subparser.add_parser("check-url", description="If you leave the options empty, you will be asked interactively.", help="check an URL and return found ISO images"); 88 | scheckurl.add_argument("--url", dest="url", help="the URL you want to check.", required=False); 89 | 90 | saddurl = subparser.add_parser("add-url", description="If you leave the options empty, you will be asked interactively.", help="add URL OS ISO sources to the JSON config file ("+ str(etcdir) +"/url_config.json)"); 91 | saddurl.add_argument("--url", dest="addurl", help="the URL you want to add.", required=False); 92 | saddurl.add_argument("--short-name", dest="sname", help="the short name of your new entry. Like 'debian' or 'ubuntu'", required=False); 93 | saddurl.add_argument("--long-name", dest="lname", help="the long name of your added entry. Like 'Debian Buster' or 'Ubuntu Bionic Beaver'", required=False); 94 | 95 | scupdate = subparser.add_parser("check-update", help="Check for updates for your installed ISO images"); 96 | 97 | supdate = subparser.add_parser("update", help="update all or specific ISO images"); 98 | supdate.add_argument("--all", action="store_true", help="try to update all ISO images"); 99 | 100 | slist = subparser.add_parser("list", help="list installed ISO images"); 101 | sstats = subparser.add_parser("stats", help="print usage statistics"); 102 | 103 | sconfig = subparser.add_parser("config", help="Modify your Ventoy device. Type config --help for more information"); 104 | sconfigsubparser = sconfig.add_subparsers(dest="configcommand"); 105 | 106 | sconfiginstall = sconfigsubparser.add_parser("install", help="Install/Update latest Ventoy software on your device"); 107 | sconfiginstall.add_argument("--gui", action="store_true", help="Opens the Ventoy GUI installer"); 108 | sconfiginstall.add_argument("-f", "--force", action="store_true", help="Force the installation with the shell installer"); 109 | 110 | sconfigmodify = sconfigsubparser.add_parser("modify", help="Modify Ventoy attributes/plugins on your Ventoy device"); 111 | sconfigmodify.add_argument("-f", "--force", action="store_true", help="Force the ..."); 112 | 113 | smodifysubparser = sconfigmodify.add_subparsers(dest="modifycommand"); 114 | 115 | smodifytheme = smodifysubparser.add_parser("theme", description="Install GRUB Themes to your Ventoy drive", help="Changing a Ventoy theme"); 116 | 117 | slastlog = subparser.add_parser("lastlog", help="Output the last (10 lines) log information ("+str(etcdir)+"/ventoyl.log)"); 118 | slastlog.add_argument("-l", "--lines", help="Specify how may lines should be printed to the output (default is 10 lines)"); 119 | 120 | args = parser.parse_args(); 121 | 122 | url_file = open(etcdir + "/url_config.json", "r"); 123 | global json_data; 124 | json_data = json.load(url_file); 125 | 126 | global verbose_mode; 127 | verbose_mode = False; 128 | if args.v: 129 | verbose_mode = True; 130 | 131 | global ventoy; 132 | 133 | if not args.l: 134 | print(ventoyu_ascii); 135 | check_root(); 136 | if args.device: 137 | try: 138 | ventoy = ventoyl.ventoyl(str(args.device), verbose_mode); 139 | except OSError: 140 | ventoy = None; 141 | else: 142 | ventoy = ventoyl.ventoyl(None, verbose_mode); 143 | 144 | #if ventoy: 145 | # if not ventoy.ventoy_device: 146 | # sys.exit( bchar.FAIL + "Error: No Ventoy device found. Plug in your Ventoy device or specify it explicity with --device"); 147 | #else: 148 | # sys.exit( bchar.FAIL + "Error: Are you sure your specified Ventoy device ("+str(args.device)+") exists? Please have a look."); 149 | if args.command == "stats": 150 | print_stats(); 151 | if args.command == "install": 152 | umount = True; 153 | short_name = ""; 154 | if args.m: 155 | umount = False; 156 | if args.short_name: 157 | short_name = args.short_name; 158 | install(umount, short_name); 159 | if args.command == "list": 160 | listfiles(); 161 | if args.command == "update": 162 | update_iso(); 163 | if args.command == "check-update": 164 | #load_wrapper("Checking for updates", check_update); 165 | check_update(); 166 | if args.command == "remove": 167 | remove_iso(); 168 | if args.command == "check-url": 169 | if args.url: 170 | checkurl(True, args.url); 171 | else: 172 | checkurl(False); 173 | if args.command == "add-url": 174 | print(args); 175 | if args.sname: 176 | s_name = args.sname; 177 | else: 178 | s_name = None; 179 | if args.lname: 180 | l_name = args.lname; 181 | else: 182 | l_name = None; 183 | if args.addurl: 184 | newurl = args.addurl; 185 | else: 186 | newurl = None; 187 | 188 | addurl(newurl, s_name, l_name); 189 | if args.command == "config": 190 | subaction = ""; 191 | if args.configcommand == "modify": 192 | subaction = args.modifycommand; 193 | action = "modify"; 194 | if args.configcommand == "install": 195 | if not args.device and not args.gui: 196 | sys.exit(bchar.FAIL + "Error: You have to explicity set your device with --device or start the GUI installer with --gui" + bchar.ENDC); 197 | action = "install"; 198 | if args.gui: 199 | action = "opengui"; 200 | if not args.configcommand: 201 | sconfig.print_help(); 202 | sys.exit(); 203 | config(action, args.force, subaction); 204 | if args.command == "lastlog": 205 | nlines = 10; 206 | if args.lines: 207 | nlines = args.lines; 208 | output_lastlog(nlines); 209 | if not args.command: 210 | print_stats(); 211 | listfiles(); 212 | 213 | def check_root (): 214 | uid = os.getuid(); 215 | if not uid == 0: 216 | sys.exit(bchar.FAIL + "Cannot access your Ventoy drive without root access.."+ bchar.ENDC +"\nTry again with"+ bchar.BOLD +" sudo " + " ".join(sys.argv) + bchar.ENDC); 217 | else: 218 | return 0; 219 | 220 | def print_stats (): 221 | 222 | if ventoy.ventoy_device: 223 | if ventoy.temp_dir: 224 | print(bchar.UNDERLINE + "Ventoy usage statistics:" + bchar.ENDC); 225 | print(bchar.BOLD + bchar.HEADER + "Total: " + bchar.ENDC + str(hr_filesize(shutil.disk_usage(ventoy.temp_dir).total))); 226 | print(bchar.BOLD + bchar.HEADER + "Used: " + bchar.ENDC + str(hr_filesize(shutil.disk_usage(ventoy.temp_dir).used))); 227 | print(bchar.BOLD + bchar.HEADER + "Free: " + bchar.ENDC + str(hr_filesize(shutil.disk_usage(ventoy.temp_dir).free))); 228 | 229 | def load_wrapper (msg, func): 230 | process = threading.Thread(name="load_wrapper_process", target=func); 231 | process.start(); 232 | while process.is_alive(): 233 | load(msg); 234 | 235 | def grequest (url): 236 | rval = requests.get(url).text; 237 | rqueue.put(rval); 238 | 239 | def install(umount=True, short_name=""): 240 | 241 | json_iterator = 0; 242 | available_os = []; 243 | 244 | if short_name == "": 245 | for os in json_data: 246 | print(bchar.BOLD + "[ID: "+ str(json_iterator) +"]"+bchar.ENDC+": " + bchar.OKGREEN + str(json_data[str(os)]["name"]) + bchar.ENDC) 247 | available_os.append(os); 248 | json_iterator += 1; 249 | 250 | select_install_os = input("Which OS do you want to install? [0-"+str(json_iterator-1)+"]: "); 251 | else: 252 | for os in json_data: 253 | available_os.append(os); 254 | try: 255 | select_install_os = str(available_os.index(str(short_name))); 256 | except ValueError: 257 | print(bchar.FAIL + "Error: Operating System " + bchar.BOLD + str(short_name) + bchar.ENDC + bchar.FAIL + " could not be found in your configuration file.\n"+bchar.HEADER+"Available are following:" + bchar.ENDC); 258 | print(", ".join([os for os in json_data])); 259 | sys.exit(); 260 | 261 | try: 262 | try: 263 | url = json_data[available_os[int(select_install_os)]]["url"]; 264 | 265 | #request = requests.get(url).text; 266 | global rqueue; 267 | rqueue = queue.Queue() 268 | request_process = threading.Thread(name="request_process", target=grequest, args=[str(url)]); 269 | request_process.start(); 270 | while request_process.is_alive(): 271 | load("Searching for installable versions"); 272 | 273 | request_result = rqueue.get(); 274 | 275 | sos_html_soup = BeautifulSoup(request_result, "html.parser"); 276 | sos_iso_images = [ node.get("href") for node in sos_html_soup.find_all("a") if node.get("href").endswith(".iso")]; 277 | sos_iso_images = list(dict.fromkeys(sos_iso_images)) 278 | os_iterator = 0; 279 | print("\n"); 280 | for image in sos_iso_images: 281 | image = image.split("/")[-1]; 282 | print(bchar.BOLD + "[ID: "+ str(os_iterator) +"]"+bchar.ENDC+": " + bchar.OKGREEN + image + bchar.ENDC); 283 | os_iterator += 1; 284 | 285 | select_os_type = input("Which OS type do you want to install? [0-"+str(os_iterator-1)+"]: "); 286 | if select_os_type == "": 287 | if len(sos_iso_images) == 1: 288 | select_os_type = "0"; 289 | 290 | url_regex = r"^http[s]:\/\/.*\/"; 291 | download_match = re.search(url_regex, sos_iso_images[int(select_os_type)]); 292 | if download_match: 293 | url = re.findall(url_regex, sos_iso_images[int(select_os_type)]); 294 | url = url[0]; 295 | sos_iso_images[int(select_os_type)] = str(sos_iso_images[int(select_os_type)]).split("/")[-1]; 296 | try: 297 | #download_url = url + sos_iso_images[int(select_os_type)]; 298 | download_file(ventoy.temp_dir, sos_iso_images[int(select_os_type)], url); 299 | print(bchar.OKGREEN + "Done. You can now use "+str(sos_iso_images[int(select_os_type)])+"..." + bchar.ENDC); 300 | if umount: 301 | umount_process = threading.Thread(name="umount_process", target=ventoy.umountVentoyDevice); 302 | umount_process.start(); 303 | while umount_process.is_alive(): 304 | load("Unmounting " + str(ventoy.ventoy_device) + "... I may still have to sync."); 305 | print("\n" + bchar.WARNING + "Ventoy device "+str(ventoy.ventoy_device)+ " umounted!" + bchar.ENDC); 306 | except IndexError or ValueError: 307 | sys.exit(bchar.FAIL + "Error: Select a valid operating system!" + bchar.ENDC); 308 | except KeyError or ValueError: 309 | sys.exit(bchar.FAIL + "Error: Interesting... Your JSON file looks broken. Cannot find parameter 'url' for os " + str(available_os[int(select_install_os)]) + bchar.ENDC); 310 | except IndexError or ValueError: 311 | sys.exit(bchar.FAIL + "Error: Select a valid operating system!" + bchar.ENDC); 312 | 313 | def check_update (silent=False): 314 | 315 | _version_search_regex = r"([0-9]{1,4}\.[0-9]{1,3}\.iso)|(([0-9]{1,4}\.[0-9]{1,4})\.[0-9]{1,4})|([0-9]{1,4}\.)"; 316 | 317 | iso_files = ventoy.getISOFiles(); 318 | 319 | if len(iso_files) < 1: 320 | if not silent: 321 | sys.exit(bchar.FAIL + "Error: Could not find any ISO images on your Ventoy device!" + bchar.ENDC); 322 | 323 | check_for_updates = {}; 324 | sum_iso_info = {}; 325 | shortlist_update = {}; 326 | 327 | for os in json_data: 328 | url = json_data[str(os)]["url"]; 329 | request_result = requests.get(url).text; 330 | 331 | html_soup = BeautifulSoup(request_result, "html.parser"); 332 | fiso_files = [ node.get("href") for node in html_soup.find_all("a") if node.get("href").endswith(".iso")]; 333 | for fil in fiso_files: 334 | fil = fil.split("/")[-1]; 335 | sum_iso_info.update({str(fil): str(url)}); 336 | 337 | if not len(sum_iso_info) > 1: 338 | if not silent: 339 | sys.exit(bchar.FAIL + "Error: Could not retrieve any iso file from your config file!" + bchar.ENDC); 340 | 341 | for iso in iso_files: 342 | iso = iso.split("/")[-1]; 343 | for siso, downloadurl in sum_iso_info.items(): 344 | similarity = SequenceMatcher(None, siso, iso).ratio(); 345 | if similarity == 1.0: 346 | if verbose_mode: 347 | if not silent: 348 | print( bchar.WARNING + "Verbose: " + bchar.OKGREEN + str(iso) + " is already the newest version!" + bchar.ENDC); 349 | break; 350 | if similarity > 0.89: 351 | shortlist_update.update({str(iso): [str(downloadurl), str(siso)]}); 352 | if verbose_mode: 353 | similarity = round(similarity*100, 1); 354 | if not silent: 355 | print(bchar.WARNING + "Verbose: Matching "+ iso +" and " + siso + " with "+bchar.BOLD+ str(similarity)+"%"+bchar.ENDC+bchar.WARNING+" similarity." + bchar.ENDC); 356 | 357 | for iso in shortlist_update: 358 | 359 | matched_similarity = shortlist_update[str(iso)][1]; 360 | matched_url = shortlist_update[str(iso)][0]; 361 | 362 | fregex = re.search(_version_search_regex, iso); 363 | sregex = re.search(_version_search_regex, matched_similarity); 364 | 365 | if fregex and sregex: 366 | frev = iso[:fregex.start()] + iso[fregex.end():]; 367 | srev = matched_similarity[:sregex.start()] + matched_similarity[sregex.end():]; 368 | 369 | similarity = SequenceMatcher(None, frev, srev).ratio(); 370 | if similarity == 1.0: 371 | check_for_updates.update({str(iso): [shortlist_update[str(iso)][0], str(matched_similarity)]}); 372 | 373 | if len(check_for_updates.items()) < 1: 374 | if not silent: 375 | if not verbose_mode: 376 | sys.exit(bchar.FAIL + "\nInfo: It seems that no ISO file on your Ventoy device is upgradable. You will get more information with " + bchar.BOLD + bchar.OKCYAN + "--verbose" + bchar.ENDC); 377 | else: 378 | sys.exit(bchar.FAIL + "\nInfo: It seems that no ISO file on your Ventoy device is upgradable." + bchar.ENDC); 379 | 380 | for i, x in check_for_updates.items(): 381 | if not silent: 382 | print(bchar.HEADER + u"\u2192 " + str(i) + bchar.ENDC + bchar.OKGREEN + " seems to be upgradable!" + bchar.ENDC); 383 | 384 | if not silent: 385 | print(bchar.OKGREEN + "Type " + bchar.OKCYAN + bchar.BOLD + "sudo " + sys.argv[0].split("/")[-1] + " update " + bchar.ENDC + bchar.OKGREEN + "to update your ISO images."+ bchar.ENDC); 386 | 387 | return check_for_updates; 388 | 389 | def remove_iso (): 390 | verbose_mode = True; 391 | listfiles(); 392 | print("\nType 'ALL' to delete all ISO images."); 393 | which_iso = input("\nWhich ISO file do you want to remove? "); 394 | ventoy_files = ventoy.getISOFiles(); 395 | if which_iso == "ALL": 396 | for iso in ventoy_files: 397 | ventoy.deleteISO(str(iso)); 398 | print("Deleted ISO file "+ str(iso) +"!"); 399 | 400 | return; 401 | 402 | try: 403 | returnval = ventoy.deleteISO(str(ventoy_files[int(which_iso)])); 404 | 405 | except ValueError: 406 | returnval = ventoy.deleteISO(str(which_iso)); 407 | 408 | if returnval: 409 | print("Deleted ISO image."); 410 | else: 411 | print("Could not delete ISO image."); 412 | 413 | def checkurl (explurl=False, url=None): 414 | 415 | checkurl = url; 416 | if not explurl: 417 | print("\nPlease type in the URL you want to check."); 418 | checkurl = input("URL: "); 419 | global rqueue; 420 | rqueue = queue.Queue() 421 | request_process = threading.Thread(name="request_process", target=grequest, args=[str(checkurl)]); 422 | request_process.start(); 423 | while request_process.is_alive(): 424 | load("Searching for installable versions"); 425 | 426 | request_result = rqueue.get(); 427 | 428 | sos_html_soup = BeautifulSoup(request_result, "html.parser"); 429 | sos_iso_images = [ node.get("href") for node in sos_html_soup.find_all("a") if node.get("href").endswith(".iso")]; 430 | os_iterator = 0; 431 | print("\n"); 432 | for image in sos_iso_images: 433 | image = image.split("/")[-1]; 434 | print(bchar.BOLD + "[ID: "+ str(os_iterator) +"]"+bchar.ENDC+": " + bchar.OKGREEN + image + bchar.ENDC); 435 | os_iterator += 1; 436 | 437 | if len(sos_iso_images) >= 1: 438 | print("\nI found "+ str(len(sos_iso_images)) +" files. You can add the URL by using following command:"); 439 | print(bchar.HEADER + sys.argv[0] + " add-url --url " + checkurl + bchar.ENDC); 440 | else: 441 | print( bchar.WARNING + "Warning: I did not found any ISO images on " + bchar.HEADER + checkurl + bchar.ENDC + bchar.WARNING + ". Please try again with another URL." + bchar.ENDC); 442 | 443 | def listfiles (): 444 | 445 | files_found = ventoy.getISOFiles(); 446 | 447 | if files_found: 448 | print(bchar.UNDERLINE + "I found following ISO images on your Ventoy device:\n" + bchar.ENDC); 449 | for iso in files_found: 450 | size = os.stat(str(iso)).st_size; 451 | size = hr_filesize(size); 452 | sizel = ""; 453 | if verbose_mode: 454 | sizel = bchar.HEADER + " ("+ str(size) +") " + bchar.ENDC; 455 | print(bchar.OKGREEN + u"\u2192 " + iso + bchar.ENDC + ""+sizel+" "+bchar.UNDERLINE+"["+str(files_found.index(iso))+"]" + bchar.ENDC); 456 | 457 | if verbose_mode: 458 | print("\nYou can use the index numbers to run an action (e.g. update or remove)"); 459 | else: 460 | print(bchar.WARNING + bchar.UNDERLINE + "Warning:"+bchar.ENDC + bchar.WARNING + "\nNo ISO images on your Ventoy device ("+ventoy.ventoy_device+") found. Maybe its not a valid Ventoy device?" + bchar.ENDC); 461 | print(bchar.HEADER + "Use following command to install ISO images: " + bchar.ENDC + bchar.BOLD + "\nsudo ventoyu install" +bchar.ENDC); 462 | 463 | def addurl (url, sname, lname): 464 | 465 | if isinstance(url, str): 466 | addurl = url; 467 | else: 468 | print("Please type in the URL you want to add to the JSON config file. You may want to check your URL with option check-url."); 469 | addurl = input("URL: "); 470 | 471 | if isinstance(sname, str): 472 | short_name = sname; 473 | else: 474 | print("Give your entry a short name like 'debian' or 'ubuntu'"); 475 | short_name = input("Short name: "); 476 | 477 | if isinstance(lname, str): 478 | long_name = lname; 479 | else: 480 | print("Give your entry a long name like 'Debian Buster' or 'Manjaro KDE'"); 481 | long_name = input("Long name: "); 482 | 483 | new_url_config = { 484 | str(short_name): { 485 | "name": str(long_name), 486 | "url": str(addurl) 487 | } 488 | }; 489 | 490 | json_data.update(new_url_config); 491 | with open(etcdir + "/url_config.json", "w") as jsonconfig: 492 | json.dump(json_data, jsonconfig, indent=4); 493 | 494 | def config (action, force=False, subaction=""): 495 | 496 | if action == "modify": 497 | options = ventoy.getPossiblePluginOptions(subaction); 498 | 499 | print(bchar.HEADER + "You need to provide following values: " + bchar.UNDERLINE + str(options) + bchar.ENDC); 500 | print(bchar.OKBLUE + "If you do not want to set a given option, just leave it empty!" + bchar.ENDC); 501 | newopts = {}; 502 | 503 | for option in options: 504 | optval = input(str(option) + ": "); 505 | newopts.update({str(option): str(optval)}); 506 | 507 | rc = ventoy.configureVentoyPlugin(subaction, newopts); 508 | if rc == False: 509 | print(bchar.FAIL + "Error: See the ventoyl log information for details. ("+bchar.OKCYAN+"sudo ventoyu lastlog"+bchar.FAIL+")" + bchar.ENDC); 510 | if action == "install": 511 | print(bchar.HEADER + "Download latest Ventoy tarball to temp directory.. Trying to open the installer..." + bchar.ENDC); 512 | ventoy.installLatestVentoy(False, force); 513 | if action == "opengui": 514 | print(bchar.HEADER + "Download latest Ventoy tarball to temp directory.. Trying to open the GUI installer..." + bchar.ENDC); 515 | ventoy.installLatestVentoy(True); 516 | 517 | def update_iso (): 518 | 519 | upgradable = check_update(True); 520 | 521 | if isinstance(upgradable, dict): 522 | if verbose_mode: 523 | print(bchar.WARNING + "Verbose: Found "+str(len(upgradable))+" upgradable images. Trying to update them..." + bchar.ENDC); 524 | 525 | for iso, isoinfo in upgradable.items(): 526 | print(bchar.HEADER + "Updating "+ bchar.BOLD + bchar.OKBLUE + str(iso) + bchar.ENDC + bchar.HEADER + " with " + bchar.BOLD + bchar.OKBLUE + str(isoinfo[1]) + bchar.ENDC + bchar.HEADER + "..." + bchar.ENDC); 527 | 528 | if not ventoy.isVentoyMounted(): 529 | ventoy.mountVentoyDevice(); 530 | 531 | try: 532 | download_file(ventoy.temp_dir, isoinfo[1], isoinfo[0]); 533 | except: 534 | print(bchar.FAIL + "Error: Could not update " + bchar.BOLD + str(iso) + bchar.ENDC + bchar.FAIL + "!" + bchar.ENDC); 535 | continue; 536 | 537 | old_iso_path = ventoy.temp_dir + "/" + iso; 538 | if os.path.isfile(old_iso_path): 539 | rc = ventoy.deleteISO(str(iso)); 540 | if rc == True: 541 | if verbose_mode: 542 | print(bchar.WARNING + "Info: Deleted the old ISO image " + str(iso) + bchar.ENDC); 543 | print(bchar.OKGREEN + "Successfully updated " + bchar.BOLD + str(iso) + bchar.ENDC + bchar.OKGREEN + "!" + bchar.ENDC); 544 | else: 545 | print(bchar.FAIL + "Error: Could not delete the old ISO image " + str(iso) + bchar.ENDC); 546 | 547 | 548 | if len(upgradable) < 1: 549 | sys.exit(bchar.FAIL + "Error: Could not found any upgradable images. Try run " + bchar.OKCYAN + bchar.BOLD + "sudo " + sys.argv[0].split("/")[-1] + " --verbose check-update"+bchar.ENDC + bchar.FAIL + " manually." + bchar.ENDC); 550 | 551 | def output_lastlog (num_lines=10): 552 | 553 | log_file = ventoy.getVentoylLogFile(); 554 | if log_file: 555 | rfile = open(log_file, "r"); 556 | lines = rfile.readlines(); 557 | for line in lines[-int(num_lines):]: 558 | print(line.rstrip("\n")); 559 | 560 | ventoyu_ascii = bchar.OKBLUE + """ 561 | _ __ __ __ __ 562 | | | / /__ ____ / /_____ __ __/ / / / 563 | | | / / _ \/ __ \/ __/ __ \/ / / / / / / 564 | | |/ / __/ / / / /_/ /_/ / /_/ / /_/ / 565 | |___/\___/_/ /_/\__/\____/\__, /\____/ 566 | /____/ 567 | """ + bchar.ENDC; 568 | 569 | if __name__ == "__main__": 570 | main(); 571 | -------------------------------------------------------------------------------- /imgs/ventoyu_install.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mawigh/ventoyu/fa8a631a3ff47a96b5ce57b107db44091b68f248/imgs/ventoyu_install.png -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | try: 2 | from setuptools import setup, find_packages; 3 | except ImportError: 4 | from distutils.core import setup; 5 | 6 | with open("README.md", "r", encoding="utf-8") as fh: 7 | long_description = fh.read(); 8 | 9 | setup( 10 | name="ventoyu", 11 | version="0.4", 12 | author="Marcel-Brian Wilkowsky", 13 | author_email="marcel.wilkowsky@hotmail.de", 14 | description="Manage and update ISO files on Ventoy devices", 15 | long_description=long_description, 16 | long_description_content_type="text/markdown", 17 | url="https://github.com/mawigh/ventoy_updater", 18 | project_urls={ 19 | "Bug Tracker": "https://github.com/mawigh/ventoy_updater/issues", 20 | }, 21 | classifiers=[ 22 | "Programming Language :: Python :: 3", 23 | "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", 24 | "Operating System :: Unix", 25 | ], 26 | include_package_data=True, 27 | scripts=["bin/ventoyu"], 28 | install_requires=["beautifulsoup4", "requests"], 29 | package_dir={"": "src"}, 30 | packages=find_packages(where="src"), 31 | ) 32 | -------------------------------------------------------------------------------- /src/ventoyl/__init__.py: -------------------------------------------------------------------------------- 1 | from .ventoyl import ventoyl; 2 | -------------------------------------------------------------------------------- /src/ventoyl/etc/url_config.json: -------------------------------------------------------------------------------- 1 | { 2 | "debianarm": { 3 | "name": "Debian (arm64)", 4 | "url": "https://cdimage.debian.org/debian-cd/current/arm64/iso-cd/" 5 | }, 6 | "debianamd": { 7 | "name": "Debian (amd64)", 8 | "url": "https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/" 9 | }, 10 | "grml": { 11 | "name": "Grml", 12 | "url": "https://download.grml.org/" 13 | }, 14 | "ubuntu1804": { 15 | "name": "Ubuntu (18.04)", 16 | "url": "https://ftp.halifax.rwth-aachen.de/ubuntu-releases/18.04/" 17 | }, 18 | "ubuntu2004": { 19 | "name": "Ubuntu (20.04)", 20 | "url": "https://ftp.halifax.rwth-aachen.de/ubuntu-releases/20.04/" 21 | }, 22 | "ubuntu2104": { 23 | "name": "Ubuntu (21.04)", 24 | "url": "https://ftp.halifax.rwth-aachen.de/ubuntu-releases/21.04/" 25 | }, 26 | "manjaroxfce": { 27 | "name": "Manjaro (XFCE)", 28 | "url": "https://manjaro.org/downloads/official/xfce/" 29 | }, 30 | "manjarokde": { 31 | "name": "Manjaro (KDE)", 32 | "url": "https://manjaro.org/downloads/official/kde/" 33 | }, 34 | "finnix123": { 35 | "name": "Finnix 123", 36 | "url": "https://www.finnix.org/releases/123/" 37 | }, 38 | "rockylinux8x64": { 39 | "name": "Rocky Linux 8 (x86_x64)", 40 | "url": "https://download.rockylinux.org/pub/rocky/8/isos/x86_64/" 41 | }, 42 | "rockylinux8aarch": { 43 | "name": "Rocky Linux 8 (aarch64)", 44 | "url": "https://download.rockylinux.org/pub/rocky/8/isos/aarch64/" 45 | }, 46 | "centos8": { 47 | "name": "CentOS 8", 48 | "url": "http://ftp.halifax.rwth-aachen.de/centos/8/isos/x86_64/" 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/ventoyl/ventoyl.py: -------------------------------------------------------------------------------- 1 | # Author: Marcel-Brian Wilkowsky (mawigh) 2 | 3 | import json; 4 | import subprocess; 5 | import shutil; 6 | import re; 7 | import sys; 8 | import tempfile; 9 | import os; 10 | import logging; 11 | import ctypes; 12 | import ctypes.util; 13 | import requests; 14 | import tarfile; 15 | 16 | class debugp: 17 | COLOR = '\033[93m'; 18 | ENDC = '\033[0m'; 19 | 20 | class ventoyl: 21 | 22 | _Ventoy_git_releases = "https://api.github.com/repos/ventoy/Ventoy/releases/latest"; 23 | _Ventoy_download_URL = "https://github.com/ventoy/Ventoy/releases/download/vRELEASE/ventoy-RELEASE-linux.tar.gz"; 24 | 25 | def __init__ (self, ventoy_device=None, debug=False): 26 | self.device_mounted = False; 27 | self.iso_images = []; 28 | self.ventoy_device = ventoy_device; 29 | self.__easysearch = True; 30 | self.device_mounted = False; 31 | self.debug = debug; 32 | 33 | self.log_file = os.path.dirname(__file__) + "/ventoyl.log"; 34 | if self.debug == True: 35 | loglevel = logging.DEBUG; 36 | else: 37 | loglevel = logging.INFO; 38 | 39 | logging.basicConfig(filename=self.log_file, format="[%(levelname)s - %(asctime)s] %(filename)s - %(funcName)s: %(message)s", encoding="utf-8", level=loglevel); 40 | 41 | if not isinstance(ventoy_device, str): 42 | rc = self.findVentoyDevice(); 43 | if not rc == False: 44 | logging.info("Found the Ventoy device: " + str(rc["name"])); 45 | 46 | rc = self.checkVentoyMount(); 47 | if rc == -1: 48 | if isinstance(ventoy_device, str): 49 | logging.error("The specified Ventoy device ("+str(ventoy_device)+") could not be found on your system."); 50 | raise OSError("The specified Ventoy device could not be found on your system."); 51 | 52 | try: 53 | self.mountVentoyDevice(); 54 | except: 55 | if isinstance(self.ventoy_device, str): 56 | logging.debug("The specified device ("+str(self.ventoy_device)+") could not be found."); 57 | 58 | def findVentoyDevice (self): 59 | 60 | ls_blkd = shutil.which("lsblk"); 61 | fdevice = ""; 62 | if ls_blkd: 63 | lsblk_out = subprocess.check_output([ls_blkd, "-Jnpo", "label,name,fstype"]); 64 | json_parse = json.loads(lsblk_out); 65 | search_pattern = "[V,v]entoy"; 66 | if isinstance(json_parse, dict): 67 | for key in json_parse["blockdevices"]: 68 | try: 69 | 70 | if key["children"]: 71 | for child in key["children"]: 72 | if re.search(search_pattern, str(child["label"])): 73 | fdevice = child; 74 | logging.debug("Found Ventoy device: " + str(child)); 75 | except KeyError: 76 | pass; 77 | else: 78 | return False; 79 | 80 | if isinstance(fdevice, dict): 81 | self.ventoy_device = fdevice["name"]; 82 | self.ventoy_devicefs = fdevice["fstype"]; 83 | return fdevice; 84 | else: 85 | return False; 86 | else: 87 | return False; 88 | 89 | def checkVentoyMount (self): 90 | if not self.ventoy_device: 91 | self.findVentoyDevice(); 92 | 93 | lsblk_out = subprocess.check_output(["lsblk","-Jnpo","name,mountpoint"]); 94 | json_parse = json.loads(lsblk_out); 95 | if isinstance(json_parse, dict): 96 | for key in json_parse["blockdevices"]: 97 | try: 98 | test = key["children"]; 99 | except KeyError: 100 | return False; 101 | for child in key["children"]: 102 | if re.search(str(self.ventoy_device), str(child["name"])): 103 | if not child["mountpoint"] == None: 104 | self.device_mounted = True; 105 | self.temp_dir = child["mountpoint"]; 106 | self.ventoy_config_dir = self.temp_dir + "/ventoy/"; 107 | return child["mountpoint"]; 108 | else: 109 | return False; 110 | else: 111 | return -1; 112 | else: 113 | return False; 114 | 115 | def createVentoyConfig (self): 116 | 117 | if not self.isVentoyMounted(): 118 | rc = self.mountVentoyDevice(); 119 | if rc == False: 120 | logging.error("Failed to mount your Ventoy drive!"); 121 | return False; 122 | 123 | if not os.path.isdir(self.ventoy_config_dir): 124 | os.mkdir(self.ventoy_config_dir); 125 | 126 | if not os.path.isfile(self.ventoy_config_dir + "/ventoy.json"): 127 | new_file = open(self.ventoy_config_dir + "/ventoy.json", "w"); 128 | new_file.write("{}"); 129 | new_file.close(); 130 | 131 | def getVentoyConfig (self): 132 | 133 | if not self.isVentoyMounted(): 134 | self.mountVentoyDevice(); 135 | 136 | if not os.path.isdir(self.ventoy_config_dir): 137 | logging.error("The Ventoy config directory does not exists. Maybe you want to create it with createVentoyConfig()?"); 138 | return -1; 139 | if not os.path.isfile(self.ventoy_config_dir + "/ventoy.json"): 140 | logging.error("The Ventoy config file does not exists. Maybe you want to create it with createVentoyConfig()?"); 141 | return -1; 142 | 143 | config_file = open(self.ventoy_config_dir + "/ventoy.json", "r"); 144 | if config_file: 145 | try: 146 | jl = json.load(config_file); 147 | return jl; 148 | except json.decoder.JSONDecodeError: 149 | logging.error("Could not parse the Ventoy config file " + str(config_file)); 150 | return False; 151 | 152 | def getVentoylLogFile (self): 153 | 154 | if self.log_file: 155 | return str(self.log_file); 156 | else: 157 | return False; 158 | 159 | def mountVentoyDevice (self): 160 | if not self.ventoy_device: 161 | return False; 162 | 163 | if not self.isVentoyMounted(): 164 | self.temp_dir = tempfile.mkdtemp(); 165 | libc = ctypes.CDLL(ctypes.util.find_library("c"), use_errno=True); 166 | libc.mount.argtypes = (ctypes.c_char_p, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_ulong, ctypes.c_char_p); 167 | 168 | return_val = libc.mount(str(self.ventoy_device).encode(), str(self.temp_dir).encode(), str(self.ventoy_devicefs).encode(), 0, "rw".encode()); 169 | if return_val < 0: 170 | logging.error("Could not mount your Ventoy device "+str(self.ventoy_device)+"!"); 171 | return False; 172 | else: 173 | logging.info("Successfully mounted Ventoy device "+str(self.ventoy_device)+" on " + str(self.temp_dir)); 174 | self.device_mounted = True; 175 | return True; 176 | 177 | def umountVentoyDevice (self): 178 | if not self.isVentoyMounted(): 179 | return False; 180 | 181 | umount_cmd = shutil.which("umount"); 182 | rc = os.system(umount_cmd + " " + self.ventoy_device); 183 | if rc == 0: 184 | logging.info("Successfully umounted Ventoy device "+str(self.ventoy_device)+"!"); 185 | return True; 186 | else: 187 | logging.error("Error trying to umount your Ventoy device "+str(self.ventoy_device)+"!"); 188 | return False; 189 | 190 | def isVentoyMounted (self): 191 | if self.device_mounted: 192 | return True; 193 | else: 194 | return False; 195 | 196 | def getVentoyMountDir (self): 197 | if self.temp_dir: 198 | return self.temp_dir; 199 | 200 | def getISOFiles (self, scan=False): 201 | 202 | if not self.ventoy_device: 203 | return []; 204 | if not self.device_mounted: 205 | return []; 206 | 207 | if self.temp_dir: 208 | for f in os.listdir(self.temp_dir): 209 | if f.endswith(".iso"): 210 | self.iso_images.append(os.path.join(self.temp_dir, f)); 211 | 212 | if len(self.iso_images) >= 1: 213 | return self.iso_images; 214 | else: 215 | return []; 216 | 217 | def deleteISO (self,iso_filename:str): 218 | if not self.ventoy_device: 219 | return False; 220 | if not self.device_mounted: 221 | return False; 222 | 223 | try: 224 | remove_iso = os.remove(iso_filename); 225 | logging.info("Successfully deleted ISO file "+str(iso_filename)); 226 | return True; 227 | except FileNotFoundError: 228 | return False; 229 | 230 | def installLatestVentoy (self, gui=False, force=False): 231 | 232 | import platform; 233 | 234 | latest_release = requests.get(self._Ventoy_git_releases); 235 | latest_release = latest_release.json(); 236 | latest_release = latest_release["tag_name"]; 237 | latest_release = latest_release.replace("v", ""); 238 | download_url = self._Ventoy_download_URL.replace("RELEASE", latest_release); 239 | file_name = download_url.split("/")[-1]; 240 | 241 | download_dir = tempfile.mkdtemp(); 242 | logging.debug("Download "+download_url+" to directory "+download_dir); 243 | 244 | download_file = requests.get(download_url); 245 | file_path = download_dir + "/" + file_name; 246 | with open(file_path, "wb") as tar_file: 247 | tar_file.write(download_file.content); 248 | 249 | if not os.path.isfile(file_path): 250 | logging.error("Cannot find file "+file_path+"!"); 251 | sys.exit("Error: Cannot find "+ file_path +"!"); 252 | else: 253 | logging.debug("Latest Ventoy release v"+ latest_release +" successfully downloaded"); 254 | 255 | if file_name.endswith(".tar.gz"): 256 | etar = tarfile.open(file_path, "r:gz"); 257 | etar.extractall(download_dir); 258 | etar.close(); 259 | elif file_name.endswiith(".tar"): 260 | etar = tarfile.open(file_path, "r:"); 261 | etar.extractall(download_dir); 262 | etar.close(); 263 | 264 | if gui == True: 265 | gui_installer_path = download_dir + "/ventoy-" + latest_release + "/VentoyGUI." + platform.uname().machine; 266 | if os.path.isfile(gui_installer_path): 267 | os.system(gui_installer_path); 268 | else: 269 | logging.error("Cannot find the GUI installer ("+gui_installer_path+"). You may want to creat an issue on https://github.com/mawigh/ventoyu/issues"); 270 | return False; 271 | else: 272 | shell_installer = download_dir + "/ventoy-" + latest_release + "/Ventoy2Disk.sh"; 273 | if os.path.isfile(shell_installer): 274 | logging.debug("Launching the Ventoy Shell Installer "+shell_installer+"..."); 275 | 276 | cmd = shell_installer + " -i " + self.ventoy_device; 277 | if force == True: 278 | cmd = shell_installer + " -I " + self.ventoy_device; 279 | os.system(cmd); 280 | else: 281 | logging.error("Cannot find the Ventoy shell installer " + shell_installer); 282 | return False; 283 | 284 | def getPossiblePlugins (self): 285 | ventoyPlugins = ["theme", "image_list"]; 286 | return ventoyPlugins; 287 | 288 | def getPossiblePluginOptions (self, plugin:str): 289 | 290 | ventoyPlugins = {"theme": ["file", "gfxmode", "display_mode", "serial_param", "ventoy_left", "ventoy_top", "ventoy_color", "fonts"]}; 291 | if not plugin in ventoyPlugins: 292 | return False; 293 | 294 | return ventoyPlugins[plugin]; 295 | 296 | 297 | def configureVentoyPlugin (self, plugintype=None, pluginoptions=False): 298 | 299 | if not self.isVentoyMounted(): 300 | rc = self.mountVentoyDevice(); 301 | if rc == False: 302 | logging.error("Could not mount Ventoy drive! Maybe you should plug it in?"); 303 | return False; 304 | 305 | vconfig = self.getVentoyConfig(); 306 | if vconfig == -1: 307 | self.createVentoyConfig(); 308 | vconfig = self.getVentoyConfig(); 309 | elif vconfig == False: 310 | return False; 311 | if not plugintype in self.getPossiblePlugins(): 312 | return False; 313 | 314 | new_plugin_config = { 315 | str(plugintype): { 316 | } 317 | }; 318 | 319 | for option, value in pluginoptions.items(): 320 | new_plugin_config[str(plugintype)].update({str(option): str(value)}); 321 | 322 | vconfig.update(new_plugin_config); 323 | with open(str(self.ventoy_config_dir) + "/ventoy.json", "w") as ventoyconfig: 324 | json.dump(vconfig, ventoyconfig, indent=4); 325 | 326 | print(vconfig); 327 | 328 | 329 | --------------------------------------------------------------------------------