├── JColor.py ├── LICENSE ├── README.md ├── config.ini └── raspcloud.py /JColor.py: -------------------------------------------------------------------------------- 1 | 2 | # colors 3 | HEADER = '\033[95m' 4 | FAIL = '\033[91m' 5 | FGBLUE2 = '\033[94m' 6 | FGGREEN2 = '\033[92m' 7 | FGORANGE = '\033[93m' 8 | FGGRAY = '\033[30m' 9 | FGRED = '\033[31m' 10 | FGGREEN = '\033[32m' 11 | FGYELLOW = '\033[33m' 12 | FGBLUE = '\033[34m' 13 | FGMAG = '\033[35m' 14 | FGCYAN = '\033[36m' 15 | FGWHITE = '\033[37m' 16 | # FGGRAY = '\033[61m' 17 | BGBLACK = '\033[40m' 18 | BGRED = '\033[41m' 19 | BGGREEN = '\033[42m' 20 | BGYELLOW = '\033[43m' 21 | BGBLUE = '\033[44m' 22 | BGMAG = '\033[45m' 23 | BGCYAN = '\033[46m' 24 | BGWHITE = '\033[47m' 25 | 26 | # end color(s) 27 | ENDC = '\033[0m' 28 | 29 | # format settings 30 | BOLDON = '\033[1m' 31 | BOLDOFF = '\033[22m' 32 | ITALON = '\033[3m' 33 | ITALOFF = '\033[23m' 34 | UNDLNON = '\033[4m' 35 | UNDLNOFF = '\033[24m' 36 | INVON = '\033[7m' 37 | INVOFF = '\033[27m' 38 | STRKTHRUON = '\033[9m' 39 | STRKTHRUOFF = '\033[29m' 40 | 41 | def success(): 42 | pass 43 | def failure(): 44 | pass 45 | 46 | def blue(input_string, bg_color='', option1='', option2='', option3=''): 47 | print option1 + option2 + option3 + bg_color + '\033[94m' + input_string + '\033[0m' + '\033[0m' + '\033[22m' + '\033[23m' + '\033[24m' + '\033[27m' + '\033[29m' 48 | def green(input_string, bg_color='', option1='', option2='', option3=''): 49 | print option1 + option2 + option3 + bg_color + '\033[92m' + input_string + '\033[0m' + '\033[0m' + '\033[22m' + '\033[23m' + '\033[24m' + '\033[27m' + '\033[29m' 50 | def red(input_string, bg_color='', option1='', option2='', option3=''): 51 | print option1 + option2 + option3 + bg_color + '\033[41m' + input_string + '\033[0m' + '\033[0m' + '\033[22m' + '\033[23m' + '\033[24m' + '\033[27m' + '\033[29m' 52 | def orange(input_string, bg_color='', option1='', option2='', option3=''): 53 | print option1 + option2 + option3 + bg_color + '\033[93m' + input_string + '\033[0m' + '\033[0m' + '\033[22m' + '\033[23m' + '\033[24m' + '\033[27m' + '\033[29m' 54 | def yellow(input_string, bg_color='', option1='', option2='', option3=''): 55 | print option1 + option2 + option3 + bg_color + '\033[43m' + input_string + '\033[0m' + '\033[0m' + '\033[22m' + '\033[23m' + '\033[24m' + '\033[27m' + '\033[29m' 56 | def gray(input_string, bg_color='', option1='', option2='', option3=''): 57 | print option1 + option2 + option3 + bg_color + '\033[94m' + input_string + '\033[0m' + '\033[0m' + '\033[22m' + '\033[23m' + '\033[24m' + '\033[27m' + '\033[29m' 58 | def white(input_string, bg_color='', option1='', option2='', option3=''): 59 | print option1 + option2 + option3 + bg_color + '\033[37m' + input_string + '\033[0m' + '\033[0m' + '\033[22m' + '\033[23m' + '\033[24m' + '\033[27m' + '\033[29m' 60 | -------------------------------------------------------------------------------- /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 | {one line to give the program's name and a brief idea of what it does.} 635 | Copyright (C) {year} {name of author} 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 | {project} Copyright (C) {year} {fullname} 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 | . -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | RaspberryCloud 2 | ============== 3 | 4 | Dropbox for Raspberry Pi! A fully functioning command-line Dropbox client built using the Dropbox Python API for Raspberry Pi. Features include downloading entire directories as zip files, editing files in a local editor, uploading/downloading, and many many more! 5 | 6 | ## Dependencies 7 | 8 | This was written in Python 2.7 and requires the Dropbox module to work. 9 | You can get it by issuing this command: 10 | ```pip install dropbox``` 11 | wget is also required. If you don't have it already, you can install it in Raspbian by entering this into the Terminal. 12 | ```apt-get install wget``` 13 | 14 | ## Supported Systems 15 | 16 | Although it's only been tested on Ubuntu 12.04 and Raspbian, it should work on most operating systems, so long as they've installed the dependencies. However, it probably won't work on Windows since there is no support for Python curses. 17 | 18 | ## Commands 19 | 20 | ``` 21 | mkdir ~ create a new folder 22 | usage: mkdir absolue_path_to_folder 23 | example: mkdir /Pictures/Family 24 | optional arguments: 25 | -h, --help show this help message and exit 26 | 27 | rm ~ delete a file/folder 28 | usage: rm absolute_path_to_file_1 absolute_path_to_file_2 absolute_path_to_file_3 etc. 29 | example: rm /Random/Other /tps_report.txt 30 | optional arguments: 31 | -h, --help show this help message and exit 32 | 33 | ls ~ print a list of files in the current directory 34 | usage: ls 35 | example: ls 36 | optional arguments: 37 | -h, --help show this help message and exit 38 | 39 | cd ~ change to another directory 40 | usage: cd directory_path_to_change_to 41 | example: cd /Pictures 42 | note: using cd by itslef will bring you back to the root directory 43 | optional arguments: 44 | -h, --help show this help message and exit 45 | 46 | cp ~ copy a file/folder from one location to another 47 | usage: cp absolute_path_to_file_with_filename new_path_to_file_with_filename 48 | example: cp /School/Essay.pdf /School/History/Essay.pdf 49 | note: if a different filename is given for the second arguement, the file will be copied and renamed 50 | optional arguments: 51 | -h, --help show this help message and exit 52 | 53 | mv ~ move a file/folder from one location to another 54 | usage: mv absolute_path_to_file_with_filename new_path_to_file_with_filename 55 | example: mv /Music/Playlist /Shared 56 | note: if a different filename is given for the second arguement, the file will be moved and renamed 57 | special usage: just like in linux, you may use this command to rename a file also. 58 | optional arguments: 59 | -h, --help show this help message and exit 60 | 61 | mlink ~ create a media link to an image/video/sound file from your Dropbox 62 | usage: mlink absolute_path_to_file 63 | example: mlink /Videos/important_video.mov 64 | optional arguments: 65 | -h, --help show this help message and exit 66 | 67 | share ~ create a link to share a file/folder 68 | usage: share absolute_path_to_file 69 | example: share /Art/ConceptArt 70 | optional arguments: 71 | -h, --help show this help message and exit 72 | 73 | upload ~ upload a file to the current directory 74 | usage: upload path_to_local_file filename 75 | example: /home/user/Documents/BeejCGuide.pdf BeejCguide.pdf 76 | note: file can be drag and dropped from the local machine into the terminal window 77 | optional arguments: 78 | -h, --help show this help message and exit 79 | 80 | dl ~ download files from current directory 81 | usage: dl filename1 filename2 filename3 filename4 etc. 82 | example: dl tps_reports.txt intro_to_c.pdf 83 | optional arguments: 84 | -c, --compress convert file/folder to .zip and download (this is the only way to download entire folders) 85 | -h, --help show this help message and exit 86 | 87 | fs ~ check size of file 88 | usage: fs filename 89 | example: fs tps_reports.txt 90 | note: does not work on folders 91 | optional arguments: 92 | -h, --help show this help message and exit 93 | 94 | use ~ use text editor of your choice to edit and save files inside your dropbox. text editor supplied must already be installed 95 | usage: use text_editor filename1 96 | example: use nano tps_reports.txt 97 | example 2: use emacs tps_reports.txt 98 | example 3: use vim tps_reports.txt 99 | optional arguments: 100 | -h, --help show this help message and exit 101 | 102 | time ~ print the current time and date 103 | usage: time 104 | example: time 105 | optional arguments: 106 | -h, --help show this help message and exit 107 | 108 | ! ~ open raspberry cloud shell 109 | usage: ! 110 | example: ! 111 | optional arguments: 112 | -h, --help show this help message and exit 113 | note: This will open the shell only, to exit the shell type '!q' 114 | This shell is identical to the bash shell except you cannot 115 | change directories. 116 | special functionality: while inside the shell you can enter 'bash' for a full blown bash shell which can be exited by pressing CTRL+D 117 | 118 | view ~ view img as thumbnail 119 | usage: view imagename preview_size 120 | example: view glamour_shot_by_deb.jpg 121 | optional arguments: 122 | -h, --help show this help message and exit 123 | note: If no image size is entered, the preview will default 124 | to medium size (128x128). Also, image sizes are displayed 125 | approximately as follows: 126 | "xs" (32x32) 127 | "s" (64x64) 128 | "m" (128x128) 129 | "l" (640x480) 130 | "xl" (1024x768) 131 | 132 | clear ~ clear the screen 133 | usage: clear 134 | example: clear 135 | optional arguments: 136 | -h, --help show this help message and exit 137 | 138 | home ~ return to the home screen of Raspberry Cloud 139 | usage: home 140 | example: home 141 | optional arguments: 142 | -h, --help show this help message and exit 143 | 144 | ? ~ view the entire list of commands 145 | useage: ? 146 | example: ? 147 | optional arguments: 148 | -h, --help show this help message and exit 149 | note: Can't be used from within the Raspberry Cloud shell or bash shell. 150 | 151 | l ~ logout and quit raspberry cloud 152 | usage: l 153 | example: l 154 | optional arguments: 155 | -h, --help show this help message and exit 156 | note: Can't be used from within the Raspberry Cloud shell or bash shell. 157 | ``` 158 | -------------------------------------------------------------------------------- /config.ini: -------------------------------------------------------------------------------- 1 | [FirstRun] 2 | first_run = True 3 | 4 | [AccessCode] 5 | access_code = empty 6 | 7 | [NickName] 8 | nick_name = empty 9 | 10 | 11 | -------------------------------------------------------------------------------- /raspcloud.py: -------------------------------------------------------------------------------- 1 | from __future__ import division 2 | import curses 3 | # Include the Dropbox SDK 4 | import dropbox 5 | import webbrowser 6 | import os 7 | import ConfigParser 8 | # import JaredColors 9 | import JColor 10 | from subprocess import call 11 | import sys 12 | import time 13 | from os.path import expanduser 14 | 15 | # the raspberry cloud graphic was created by me, and I reserve all rights 16 | # if you would like to use it, please contact me first and give me credit as well. 17 | # 18 | # Author: Jared Marshall Hall 19 | # Website: http://www.jaredmhall.com 20 | # Contact: hall.jared.m@gmail.com 21 | # Created: May 23, 2014 22 | # Updated: July 10, 2014 23 | # Why: I saw the need for Dropbox after getting my first Raspberry Pi 24 | # and couldn't find an app for it. So I decided after taking a look 25 | # at the Dropbox API to make one myself. I'm sorry for the horrible, 26 | # unoptimized spaghetti code. It's quite possible that by reviewing this 27 | # source code, you may in fact learn a great deal about how NOT to program. 28 | # I strung it together over the period of a about a week, with the commuinity at 29 | # heart. I really hope that this is useful for some of you. That will 30 | # make it worth it. If this app was helpful please consider donating to help 31 | # me pay my bills, I'm a poor college student. You can find the donation info 32 | # on the homescreen of the app but here it is again. 33 | # 34 | # Donate Bitcoin: 35 | # 1AYk yF8P 1k19 NpAA xxEm WBa6 rp7g wgHz dr 36 | # 37 | # Donate Dogecoin: 38 | # DBGX4dwhD7SHhfcgzKjSZ2yJDhruAPgPUP 39 | # 40 | # Donate via Paypal: 41 | # http://bit.ly/1klxN1M 42 | # 43 | # However, what I'd really love more than a donation is a job! I'm fresh out of college 44 | # and haven't had much luck finding one. I know it's a long shot, but if you are interested 45 | # in hiring me, full-time part-time or on a freelance basis, please email me 46 | # at hall.jared.m@gmail.com and let me know! My resume is available on my website at 47 | # http://www.jaredmhall.com. I'm also the proud creator of http://www.doge4.us as well 48 | # as the android app over at http://goo.gl/JpeJFV. So if you're into that sort of thing, 49 | # give 'em a look sometime! Stay stoked my friends! 50 | # 51 | # 52 | 53 | # to keep things looking fresh 54 | def clearscreen(): 55 | os.system('cls' if os.name == 'nt' else 'clear') 56 | 57 | # initiate the curses library for the homescreen 58 | def init_curses(): 59 | s = curses.initscr() 60 | curses.start_color() 61 | curses.use_default_colors() 62 | curses.noecho() 63 | s.scrollok(1) 64 | curses.curs_set(0) 65 | s.keypad(1) 66 | s.refresh() 67 | return s 68 | 69 | def donate(s): 70 | curses.endwin() 71 | clearscreen() 72 | print JColor.FGYELLOW + JColor.BOLDON + "Donate Bitcoin" + JColor.ENDC + JColor.BOLDOFF 73 | print "19Ve bRAu 8ZdT zf7A JnJv dCyh qSBZ qMon T\n" 74 | print JColor.FGYELLOW + JColor.BOLDON + "Donate Dogecoin" + JColor.ENDC + JColor.BOLDOFF 75 | print "DBGX4dwhD7SHhfcgzKjSZ2yJDhruAPgPUP\n" 76 | print JColor.FGYELLOW + JColor.BOLDON + "Donate via Paypal" + JColor.ENDC + JColor.BOLDOFF 77 | print "http://bit.ly/1klxN1M\n" 78 | print JColor.FGGREEN + JColor.BOLDON + """ 79 | However, what I'd really love more than a donation is a job! I'm fresh out 80 | of college and haven't had much luck finding one. I know it's a long shot, 81 | but if you are interested in hiring me, full-time, part-time or on 82 | a freelance basis, please email me at hall.jared.m@gmail.com and let 83 | me know! My resume is available on my website at 84 | http://www.jaredmhall.com. I'm also the proud creator of 85 | http://www.doge4.us as well as the android app over at 86 | http://goo.gl/JpeJFV. So if you're into that sort of thing, 87 | give 'em a look sometime! Thank you for your time and stay stoked!\n""" + JColor.ENDC + JColor.BOLDOFF 88 | print raw_input("Press [ENTER] to continue..") 89 | start_raspberry_cloud(s) 90 | 91 | def contact(s): 92 | curses.endwin() 93 | clearscreen() 94 | print JColor.FGYELLOW + JColor.BOLDON + "Email" + JColor.ENDC + JColor.BOLDOFF 95 | print "hall.jared.m@gmail.com\n" 96 | print raw_input("Press [ENTER] to continue..") 97 | start_raspberry_cloud(s) 98 | 99 | def help(s): 100 | curses.endwin() 101 | clearscreen() 102 | print JColor.FGWHITE + JColor.BOLDON + """ 103 | ____ ____ ____ ____ 104 | ||h ||||e ||||l ||||p || 105 | ||__||||__||||__||||__|| 106 | |/__\||/__\||/__\||/__\| 107 | 108 | """ + JColor.ENDC + JColor.BOLDOFF + """ 109 | There are several dependencies for this program, they are: wget & dropbox 110 | To install, enter these into the command line: 111 | sudo apt-get install wget 112 | sudo pip install dropbox 113 | """ 114 | print JColor.FGWHITE + JColor.BOLDON + """ 115 | ____ ____ ____ ____ ____ 116 | ||o ||||t ||||h ||||e ||||r || 117 | ||__||||__||||__||||__||||__|| 118 | |/__\||/__\||/__\||/__\||/__\| 119 | 120 | """ + JColor.ENDC + JColor.BOLDOFF + """ 121 | Other stuff: 122 | - Raspberry Cloud does not like spaces! 123 | 124 | command short list 125 | """ 126 | print JColor.FGWHITE + JColor.BOLDON + """ 127 | ____ ____ ____ ____ ____ ____ ____ 128 | ||c ||||o ||||m ||||a ||||n ||||d ||||s || 129 | ||__||||__||||__||||__||||__||||__||||__|| 130 | |/__\||/__\||/__\||/__\||/__\||/__\||/__\| 131 | 132 | """ + JColor.ENDC + """mkdir ~ create a new folder 133 | usage: mkdir absolue_path_to_folder 134 | example: mkdir /Pictures/Family 135 | optional arguments: 136 | -h, --help show this help message and exit 137 | 138 | rm ~ delete a file/folder 139 | usage: rm absolute_path_to_file_1 absolute_path_to_file_2 absolute_path_to_file_2 etc. 140 | example: rm /Random/Other /tps_report.txt 141 | optional arguments: 142 | -h, --help show this help message and exit 143 | 144 | ls ~ print a list of files in the current directory 145 | usage: ls 146 | example: ls 147 | optional arguments: 148 | -h, --help show this help message and exit 149 | 150 | cd ~ change to another directory 151 | usage: cd directory_path_to_change_to 152 | example: cd /Pictures 153 | note: using cd by itslef will bring you back to the root directory 154 | optional arguments: 155 | -h, --help show this help message and exit 156 | 157 | cp ~ copy a file/folder from one location to another 158 | usage: cp absolute_path_to_file_with_filename new_path_to_file_with_filename 159 | example: cp /School/Essay.pdf /School/History/Essay.pdf 160 | note: if a different filename is given for the second arguement, the file will be copied and renamed 161 | optional arguments: 162 | -h, --help show this help message and exit 163 | 164 | mv ~ move a file/folder from one location to another 165 | usage: mv absolute_path_to_file_with_filename new_path_to_file_with_filename 166 | example: mv /Music/Playlist /Shared 167 | note: if a different filename is given for the second arguement, the file will be moved and renamed 168 | special usage: just like in linux, you may use this command to rename a file also. 169 | optional arguments: 170 | -h, --help show this help message and exit 171 | 172 | mlink ~ create a media link to an image/video/sound file from your Dropbox 173 | usage: mlink absolute_path_to_file 174 | example: mlink /Videos/important_video.mov 175 | optional arguments: 176 | -h, --help show this help message and exit 177 | 178 | share ~ create a link to share a file/folder 179 | usage: share absolute_path_to_file 180 | example: share /Art/ConceptArt 181 | optional arguments: 182 | -h, --help show this help message and exit 183 | 184 | upload ~ upload a file to the current directory 185 | usage: upload path_to_local_file filename 186 | example: /home/user/Documents/BeejCGuide.pdf BeejCguide.pdf 187 | note: file can be drag and dropped from the local machine into the terminal window 188 | optional arguments: 189 | -h, --help show this help message and exit 190 | 191 | dl ~ download files from current directory 192 | usage: dl filename1 filename2 filename3 filename4 etc. 193 | example: dl tps_reports.txt intro_to_c.pdf 194 | optional arguments: 195 | -c, --compress convert file/folder to .zip and download (this is the only way to download entire folders) 196 | -h, --help show this help message and exit 197 | 198 | fs ~ check size of file 199 | usage: fs filename 200 | example: fs tps_reports.txt 201 | note: does not work on folders 202 | optional arguments: 203 | -h, --help show this help message and exit 204 | 205 | use ~ use text editor of your choice to edit and save files inside your dropbox. text editor supplied must already be installed 206 | usage: use text_editor filename1 207 | example: use nano tps_reports.txt 208 | example 2: use emacs tps_reports.txt 209 | example 3: use vim tps_reports.txt 210 | optional arguments: 211 | -h, --help show this help message and exit 212 | 213 | time ~ print the current time and date 214 | usage: time 215 | example: time 216 | optional arguments: 217 | -h, --help show this help message and exit 218 | 219 | ! ~ open raspberry cloud shell 220 | usage: ! 221 | example: ! 222 | optional arguments: 223 | -h, --help show this help message and exit 224 | note: This will open the shell only, to exit the shell type '!q' 225 | This shell is identical to the bash shell except you cannot 226 | change directories. 227 | special functionality: while inside the shell you can enter 'bash' for a full blown bash shell which can be exited by pressing CTRL+D 228 | 229 | view ~ view img as thumbnail 230 | usage: view imagename preview_size 231 | example: view glamour_shot_by_deb.jpg 232 | optional arguments: 233 | -h, --help show this help message and exit 234 | note: If no image size is entered, the preview will default 235 | to medium size (128x128). Also, image sizes are displayed 236 | approximately as follows: 237 | "xs" (32x32) 238 | "s" (64x64) 239 | "m" (128x128) 240 | "l" (640x480) 241 | "xl" (1024x768) 242 | 243 | clear ~ clear the screen 244 | usage: clear 245 | example: clear 246 | optional arguments: 247 | -h, --help show this help message and exit 248 | 249 | home ~ return to the home screen of Raspberry Cloud 250 | usage: home 251 | example: home 252 | optional arguments: 253 | -h, --help show this help message and exit 254 | 255 | ? ~ view the entire list of commands 256 | useage: ? 257 | example: ? 258 | optional arguments: 259 | -h, --help show this help message and exit 260 | note: Can't be used from within the Raspberry Cloud shell or bash shell. 261 | 262 | l ~ logout and quit raspberry cloud 263 | usage: l 264 | example: l 265 | optional arguments: 266 | -h, --help show this help message and exit 267 | note: Can't be used from within the Raspberry Cloud shell or bash shell. 268 | """ 269 | print raw_input("Press [ENTER] to continue..") 270 | start_raspberry_cloud(s) 271 | 272 | # this awesome explosion graphic was pulled from the 'boxes' terminal app created Thomas Jensen 273 | # the graphic itself was created by Joan G. Stark 274 | # -- I only modified it a bit and added color. 275 | def error_img(error_string): 276 | print JColor.FGORANGE + JColor.BOLDON + """ 277 | _ ._ _ , _ ._ 278 | (_ ' ( ` )_ .__) 279 | ( ( ( ) `) ) _) 280 | (__ (_ (_ . _) _) ,__) """ + JColor.ENDC + JColor.BOLDOFF + JColor.FGORANGE + """ 281 | `~~`\ ' . /`~~` """ + JColor.ENDC + JColor.FGWHITE + JColor.BOLDON + """ 282 | ,::: ; ; :::, 283 | ':::::::::::::::' """ + JColor.ENDC + JColor.BOLDOFF + JColor.FGORANGE + """ 284 | /_ __ \ """ + JColor.ENDC + JColor.FGRED + """ 285 | Error: """ + error_string + JColor.ENDC 286 | 287 | # didn't use this because i wanted to separate the colors 288 | # the those are clouds in the background btw ;) 289 | def splash_screen(s, y, x): 290 | # splash_logo = """ 291 | # ----. .---- 292 | # '. \ '_' / .' 293 | # .- ( ) -. 294 | # ( .-.'-'.-. ) 295 | # - ( ) ( ) - ,,, 296 | # ,,,,,,,, ( )'-'.-.'-'( ) ),, 297 | # ,( ), - .- ( ) -. - ,,) 298 | # (,, ( ) '-' ( ) ,,,, ),, 299 | # (,,,, '- ( ) -' ), 300 | # (,,,,,,,) '-' ,,,,) RASPBERRY CLOUD 301 | # ,,( ______________ ,,,,),, V 1.0 302 | # ,,,,,,(,,____/_____________/____ ,) BY JARED MARSHALL HALL 303 | # ( / /| |/ /,,),,,,, 304 | #(,,, /___/_|____________/___/ ,,,) 305 | # (,, ,,, /______________/| ,,) 306 | # (,, ,,| ||,,,,, ,,) 307 | # ,,,,,( | || ) 308 | # (,,, |_____________|/ ,,) 309 | # (,, ,,,,,,,,,) 310 | # (,,,,,,,,,,) 311 | #""" 312 | 313 | # use curses library to print out the logo with colors 314 | s.addstr(1, 26, "----. .----", curses.color_pair(1)) 315 | s.addstr(2, 26, "'. \ '_' / .'", curses.color_pair(1)) 316 | s.addstr(3, 27, ".- ( ) -.", curses.color_pair(2)) 317 | s.addstr(4, 26, "( .-.'-'.-. )", curses.color_pair(2)) 318 | s.addstr(4, 25, "- ( ) ( ) -", curses.color_pair(2)) 319 | s.addstr(4, 42, ",,,", curses.color_pair(3)) 320 | s.addstr(5, 14, ",,,,,,,,", curses.color_pair(3)) 321 | s.addstr(5, 24, "( )'-'.-.'-'( )", curses.color_pair(2)) 322 | s.addstr(5, 45, "),,", curses.color_pair(3)) 323 | s.addstr(6, 12, ",( ),", curses.color_pair(3)) 324 | s.addstr(6, 25, "- .- ( ) -. -", curses.color_pair(2)) 325 | s.addstr(6, 46, ",,)", curses.color_pair(3)) 326 | s.addstr(7, 11, "(,,", curses.color_pair(3)) 327 | s.addstr(7, 26, "( ) '-' ( )", curses.color_pair(2)) 328 | s.addstr(7, 41, ",,,, ),,", curses.color_pair(3)) 329 | s.addstr(8, 15, "(,,,,", curses.color_pair(3)) 330 | s.addstr(8, 27, "'- ( ) -'", curses.color_pair(2)) 331 | s.addstr(8, 49, "),", curses.color_pair(3)) 332 | s.addstr(9, 19, "(,,,,,,,)", curses.color_pair(3)) 333 | s.addstr(9, 31, "'-'", curses.color_pair(2)) 334 | s.addstr(9, 47, ",,,,)", curses.color_pair(3)) 335 | s.addstr(4, 60, "RASPBERRY CLOUD", curses.color_pair(4)) 336 | s.addstr(10, 20, ",,(", curses.color_pair(3)) 337 | s.addstr(10, 27, "______________", curses.color_pair(5)) 338 | s.addstr(10, 42, ",,,,),,", curses.color_pair(3)) 339 | s.addstr(5, 70, "V 1.0", curses.color_pair(4)) 340 | s.addstr(11, 13, ",,,,,,(,,", curses.color_pair(3)) 341 | s.addstr(11, 22, "____/_____________/____", curses.color_pair(5)) 342 | s.addstr(11, 48, ",)", curses.color_pair(3)) 343 | s.addstr(6, 53, "BY JARED MARSHALL HALL", curses.color_pair(4)) 344 | s.addstr(12, 12, "(", curses.color_pair(3)) 345 | s.addstr(12, 21, "/ /| |/ /", curses.color_pair(5)) 346 | s.addstr(12, 45, ",,),,,,,", curses.color_pair(3)) 347 | s.addstr(7, 67, "(c) 2014", curses.color_pair(4)) 348 | s.addstr(13, 11, "(,,,", curses.color_pair(3)) 349 | s.addstr(13, 20, "/___/_|____________/___/", curses.color_pair(5)) 350 | s.addstr(13, 50, ",,,)", curses.color_pair(3)) 351 | s.addstr(14, 15, "(,, ,,,", curses.color_pair(3)) 352 | s.addstr(14, 23, "/______________/|", curses.color_pair(5)) 353 | s.addstr(14, 50, ",,)", curses.color_pair(3)) 354 | s.addstr(15, 15, "(,, ,,", curses.color_pair(3)) 355 | s.addstr(15, 24, "| ||", curses.color_pair(5)) 356 | s.addstr(15, 40, " ,,,,, ,,)", curses.color_pair(3)) 357 | s.addstr(16, 16, ",,,,,(", curses.color_pair(3)) 358 | s.addstr(16, 24, "| ||", curses.color_pair(5)) 359 | s.addstr(16, 45, ")", curses.color_pair(3)) 360 | s.addstr(17, 15, "(,,,", curses.color_pair(3)) 361 | s.addstr(17, 24, "|_____________|/", curses.color_pair(5)) 362 | s.addstr(17, 44, ",,)", curses.color_pair(3)) 363 | s.addstr(18, 19, "(,,", curses.color_pair(3)) 364 | s.addstr(18, 34, ",,,,,,,,,)", curses.color_pair(3)) 365 | s.addstr(19, 22, "(,,,,,,,,,,)", curses.color_pair(3)) 366 | 367 | s.addstr(17, 51, "> ", curses.color_pair(3)) 368 | s.addstr(17, 53, "Start Raspberry Cloud", curses.color_pair(6)) 369 | s.addstr(18, 53, "Donate", curses.color_pair(3)) 370 | s.addstr(19, 53, "Contact", curses.color_pair(3)) 371 | s.addstr(20, 53, "Help", curses.color_pair(3)) 372 | s.addstr(21, 53, "Quit", curses.color_pair(3)) 373 | 374 | # this is to keep track of where we are in the menu 375 | menu_pointer = 17 376 | 377 | # create the loop for the menu 378 | while(1): # AKA while True 379 | 380 | # store selection in a variable 381 | c = s.getch() 382 | 383 | 384 | if c == curses.KEY_DOWN: 385 | if menu_pointer >=21: 386 | s.addstr(menu_pointer, 51, " ", curses.color_pair(3)) 387 | menu_pointer = 16 388 | # for item in menu_list: 389 | menu_pointer += 1 390 | s.addstr(menu_pointer - 1, 51, " ", curses.color_pair(3)) 391 | s.addstr(menu_pointer, 51, ">", curses.color_pair(3)) 392 | #s.addstr(18, 51, "Donate", curses.color_pair(3)) 393 | #s.addstr(19, 53, "Contact", curses.color_pair(3)) 394 | #s.addstr(20, 53, "Help", curses.color_pair(3)) 395 | s.refresh() 396 | elif c == curses.KEY_UP: 397 | if menu_pointer <=17: 398 | s.addstr(menu_pointer, 51, " ", curses.color_pair(3)) 399 | menu_pointer = 22 400 | # for item in menu_list: 401 | menu_pointer -= 1 402 | s.addstr(menu_pointer + 1, 51, " ", curses.color_pair(3)) 403 | s.addstr(menu_pointer, 51, ">", curses.color_pair(3)) 404 | #s.addstr(18, 51, "Donate", curses.color_pair(3)) 405 | #s.addstr(19, 53, "Contact", curses.color_pair(3)) 406 | #s.addstr(20, 53, "Help", curses.color_pair(3)) 407 | s.refresh() 408 | elif c == ord('q'): 409 | break # Exit the while() 410 | if menu_pointer == 17: 411 | s.addstr(17, 53, "Start Raspberry Cloud", curses.color_pair(6)) 412 | s.addstr(18, 53, "Donate", curses.color_pair(3)) 413 | s.addstr(19, 53, "Contact", curses.color_pair(3)) 414 | s.addstr(20, 53, "Help", curses.color_pair(3)) 415 | s.addstr(21, 53, "Quit", curses.color_pair(3)) 416 | s.refresh() 417 | # I chose the right arrow key because the enter key is unreliable 418 | if c == curses.KEY_RIGHT: 419 | start_raspberry_cloud(s) 420 | elif menu_pointer == 18: 421 | s.addstr(17, 53, "Start Raspberry Cloud", curses.color_pair(3)) 422 | s.addstr(18, 53, "Donate", curses.color_pair(6)) 423 | s.addstr(19, 53, "Contact", curses.color_pair(3)) 424 | s.addstr(20, 53, "Help", curses.color_pair(3)) 425 | s.addstr(21, 53, "Quit", curses.color_pair(3)) 426 | s.refresh() 427 | if c == curses.KEY_RIGHT: 428 | donate(s) 429 | elif menu_pointer == 19: 430 | s.addstr(17, 53, "Start Raspberry Cloud", curses.color_pair(3)) 431 | s.addstr(18, 53, "Donate", curses.color_pair(3)) 432 | s.addstr(19, 53, "Contact", curses.color_pair(6)) 433 | s.addstr(20, 53, "Help", curses.color_pair(3)) 434 | s.addstr(21, 53, "Quit", curses.color_pair(3)) 435 | s.refresh() 436 | if c == curses.KEY_RIGHT: 437 | contact(s) 438 | elif menu_pointer == 20: 439 | s.addstr(17, 53, "Start Raspberry Cloud", curses.color_pair(3)) 440 | s.addstr(18, 53, "Donate", curses.color_pair(3)) 441 | s.addstr(19, 53, "Contact", curses.color_pair(3)) 442 | s.addstr(20, 53, "Help", curses.color_pair(6)) 443 | s.addstr(21, 53, "Quit", curses.color_pair(3)) 444 | s.refresh() 445 | if c == curses.KEY_RIGHT: 446 | help(s) 447 | elif menu_pointer == 21: 448 | s.addstr(17, 53, "Start Raspberry Cloud", curses.color_pair(3)) 449 | s.addstr(18, 53, "Donate", curses.color_pair(3)) 450 | s.addstr(19, 53, "Contact", curses.color_pair(3)) 451 | s.addstr(20, 53, "Help", curses.color_pair(3)) 452 | s.addstr(21, 53, "Quit", curses.color_pair(6)) 453 | s.refresh() 454 | if c == curses.KEY_RIGHT: 455 | curses.endwin() 456 | clearscreen() 457 | sys.exit() 458 | 459 | def format_date(and_time=None): 460 | months = ('Null','January','February','March','April','May','June','July','August','September','October','November','December') 461 | curr_day = time.strftime("%d") 462 | curr_month = time.strftime("%m").strip('0') 463 | curr_year = time.strftime("%G") 464 | counter = 0 465 | for month in months: 466 | # print month 467 | # print counter + 1 468 | # print (str(curr_month) + ' and ' + str(counter + 1)) 469 | if str(curr_month) == str(counter - 1): 470 | # print "[+]\t match found ------------> " + months[counter + 1] 471 | curr_month = months[counter - 1] 472 | counter += 1 473 | formatted_date = curr_month + ' ' + curr_day + ', ' + curr_year 474 | formatted_time = time.strftime("%I:%M:%S %p") # Hour Minute Second and the %p is for AM PM ;) 475 | if and_time == True: 476 | formatted_datetime = str(formatted_time) + ' ~ ' + str(formatted_date) 477 | return formatted_datetime 478 | else: 479 | return formatted_date 480 | 481 | def format_time(): 482 | formatted_time = time.strftime("%I:%M:%S %p") # Hour Minute Second and the %p is for AM PM ;) 483 | return formatted_time 484 | 485 | # this text was created using the ascii text generator over at http://patorjk.com/software/taag/ 486 | def home_screen(nickname, logged_in=True): 487 | formatted_date = format_date() 488 | formatted_time = format_time() 489 | if logged_in == True: 490 | print JColor.FGRED + JColor.BOLDON + """________ ______ 491 | ___ __ \______ _________________ ___ /_ _____ _____________________ __ 492 | __ /_/ /_ __ `/__ ___/___ __ \__ __ \_ _ \__ ___/__ ___/__ / / / 493 | _ _, _/ / /_/ / _(__ ) __ /_/ /_ /_/ // __/_ / _ / _ /_/ / 494 | /_/ |_| \__,_/ /____/ _ .___/ /_.___/ \___/ /_/ /_/ _\__, / 495 | /_/ /____/ """ + JColor.ENDC + JColor.BOLDOFF + JColor.FGWHITE + JColor.BOLDON +""" 496 | _______________ _________ 497 | __ ____/___ /______ ____ ________ / 498 | _ / __ / _ __ \_ / / /_ __ / 499 | / /___ _ / / /_/ // /_/ / / /_/ / 500 | \____/ /_/ \____/ \__,_/ \__,_/ 501 | """ + JColor.ENDC + JColor.BOLDOFF + """ 502 | Hello """ + JColor.FGCYAN + JColor.BOLDON + nickname + JColor.ENDC + JColor.BOLDOFF + """! Welcome to Raspberry Cloud. 503 | You are logged in. 504 | The date is """+ JColor.FGWHITE + formatted_date + JColor.ENDC +""" and the current time is """+ JColor.FGWHITE+formatted_time+JColor.ENDC+""" 505 | You can enter """+ JColor.FGORANGE + JColor.BOLDON +"""ls"""+ JColor.ENDC + JColor.BOLDOFF +""" to print your home directory or """+ JColor.FGORANGE + JColor.BOLDON +"""?"""+ JColor.ENDC + JColor.BOLDOFF +""" for more help.""" 506 | else: 507 | print JColor.FGRED + JColor.BOLDON + """________ ______ 508 | ___ __ \______ _________________ ___ /_ _____ _____________________ __ 509 | __ /_/ /_ __ `/__ ___/___ __ \__ __ \_ _ \__ ___/__ ___/__ / / / 510 | _ _, _/ / /_/ / _(__ ) __ /_/ /_ /_/ // __/_ / _ / _ /_/ / 511 | /_/ |_| \__,_/ /____/ _ .___/ /_.___/ \___/ /_/ /_/ _\__, / 512 | /_/ /____/ """ + JColor.ENDC + JColor.BOLDOFF + JColor.FGWHITE + JColor.BOLDON +""" 513 | _______________ _________ 514 | __ ____/___ /______ ____ ________ / 515 | _ / __ / _ __ \_ / / /_ __ / 516 | / /___ _ / / /_/ // /_/ / / /_/ / 517 | \____/ /_/ \____/ \__,_/ \__,_/ 518 | """ + JColor.ENDC + JColor.BOLDOFF + """ 519 | Hello """ + JColor.FGCYAN + JColor.BOLDON + nickname + JColor.ENDC + JColor.BOLDOFF + """! Welcome to Raspberry Cloud. 520 | You are not logged in. 521 | The date is """+ JColor.FGWHITE + formatted_date + JColor.ENDC +""" and the current time is """+ JColor.FGWHITE+formatted_time+JColor.ENDC #+""" 522 | # You can enter """+ JColor.FGORANGE + JColor.BOLDON +"""ls"""+ JColor.ENDC + JColor.BOLDOFF +""" to print your home directory or """+ JColor.FGORANGE + JColor.BOLDON +"""?"""+ JColor.ENDC + JColor.BOLDOFF +""" for more help.""" 523 | 524 | 525 | # put our app to work! 526 | def start_raspberry_cloud(s): 527 | # i decided to end the curses window here 528 | # i realize how nice it would be to be able 529 | # to navigate with the arrow keys like the main menu 530 | # but things get a little crazy when the size of your 531 | # directory goes beyond the height of the terminal 532 | # so i decided to keep things simple 533 | curses.endwin() 534 | 535 | # create a function to access our dropbox accound 536 | def access_dropbox(access_token, user_id): 537 | 538 | clearscreen() 539 | 540 | # get info about our dropbox 541 | client = dropbox.client.DropboxClient(access_token) 542 | 543 | 544 | # the first thing we need to do is print the directory so 545 | # we can get our bearings 546 | def print_dir(access_token, user_id, foldername): 547 | 548 | 549 | # stick folder info in a variable 550 | folder_metadata = client.metadata(foldername) 551 | 552 | # store folders in a dict 553 | folder_metadata_dict = folder_metadata 554 | 555 | formatted_date = format_date() 556 | formatted_time = format_time() 557 | 558 | # i hate these kinds of things, i really do 559 | # this was such a pain for me to figure out 560 | # in case you are wondering, i'm looping through the folder dict 561 | # and pulling out the names so they can be displayed 562 | for key, value in folder_metadata_dict.iteritems(): 563 | if type(value) is list: 564 | for listitem in value: 565 | if type(listitem) is dict: 566 | #print listitem 567 | for nested_key, nested_value in listitem.iteritems(): 568 | if nested_key == 'path': 569 | print JColor.FGORANGE + nested_value + JColor.ENDC 570 | print JColor.FGWHITE + "--------------------------------------------------" + formatted_time + ' ~ ' + formatted_date + JColor.ENDC 571 | 572 | settings = ConfigParser.ConfigParser() 573 | f = open("config.ini","r") 574 | settings.readfp(f) 575 | nickname = settings.get('NickName', 'nick_name') 576 | f.close() 577 | 578 | home_screen(nickname) 579 | # finally we print our root directory 580 | #print_dir(access_token, user_id, '/') 581 | 582 | # this is how we will get our info from the user 583 | def get_command(): 584 | handle_input = raw_input(JColor.BOLDON + JColor.FGCYAN + "\n>> " + JColor.ENDC + JColor.BOLDOFF) 585 | return handle_input 586 | 587 | # a nifty function to check file size. doesn't work on folders 588 | def check_filesize(current_dir, name_of_file, client): 589 | 590 | # list client folders 591 | folder_metadata = client.metadata(current_dir) 592 | 593 | # store folders in a dict 594 | folder_metadata_dict = folder_metadata 595 | for key, value in folder_metadata_dict.iteritems(): 596 | #print value 597 | if type(value) is list: 598 | for listitem in value: 599 | if type(listitem) is dict: 600 | #print listitem 601 | for nested_key, nested_value in listitem.iteritems(): 602 | # print "looping through data" 603 | if (nested_key == 'path'): 604 | # print "found path" + nested_value 605 | if (nested_value == (current_dir + "/" + name_of_file)) or (nested_value.lower() == current_dir + "/" + name_of_file.lower()): 606 | current_dir = nested_value 607 | if name_of_file in current_dir: 608 | current_dir = current_dir.replace(name_of_file, "") 609 | print current_dir + name_of_file + ": " + str(listitem['bytes']) + " bytes" 610 | file_size = listitem['bytes'] 611 | return str(file_size) + " bytes" 612 | elif (nested_value == "/" + name_of_file) or (nested_value.lower() == "/" + name_of_file): 613 | current_dir = nested_value 614 | if name_of_file in current_dir: 615 | current_dir = current_dir.replace(name_of_file, "") 616 | current_dir = "/" 617 | print current_dir + name_of_file + ": " + str(listitem['bytes']) + " bytes" 618 | file_size = listitem['bytes'] 619 | return str(file_size) + " bytes" 620 | 621 | # this didn't work :/ may fix it later 622 | def convert_bytes(bytes): 623 | bytes_d = bytes 624 | bytes = bytes_d 625 | kilobytes_d = bytes / 1024 626 | kilobytes = kilobytes_d 627 | megabytes_d = bytes / 1048576 628 | megabytes = megabytes_d 629 | gigabytes_d = bytes / 1073741824 630 | gigabytes = gigabytes_d 631 | if gigabytes_d is not None: 632 | return gigabytes 633 | elif megabytes_d is not None: 634 | return megabytes 635 | elif kilobytes_d is not None: 636 | return kilobytes 637 | elif bytes_d is not None: 638 | return bytes 639 | 640 | # for uploading files 641 | def new_upload(current_dir, path_to_file, upload_file_name, client): 642 | new_file_name = current_dir + "/" + upload_file_name 643 | local_file_size = os.stat(path_to_file).st_size 644 | 645 | # if file is bigger than or equal to 4MB 646 | # use the chunked uploader (apparently 647 | # better for bigger files) 648 | # else 649 | # use the regular put_file() function 650 | if (local_file_size >= 4194304): 651 | print "uploading " + path_to_file + " to " + current_dir 652 | big_file = open(path_to_file, 'rb') 653 | uploader = client.get_chunked_uploader(big_file, local_file_size) 654 | while uploader.offset < local_file_size: 655 | try: 656 | upload = uploader.upload_chunked() 657 | except rest.ErrorResponse, e: 658 | # perform error handling and retry logic 659 | print e 660 | raise 661 | uploader.finish(current_dir + "/" + upload_file_name, True) 662 | clearscreen() 663 | print_dir(access_token, user_id, current_dir) 664 | print "[+]\tsuccessfully uploaded " + upload_file_name 665 | #upload_file_size = check_filesize(current_dir, upload_file_name, client) 666 | # print "uploaded " + convert_bytes(upload_file_size) + " of " + convert_bytes(local_file_size) 667 | # print "[+]\tsuccessfully uploaded " + upload_file_name + " to " + current_dir 668 | else: 669 | try: 670 | f = open(path_to_file, 'rb') 671 | target = client.put_file(current_dir + "/" + upload_file_name, f, True) 672 | upload_file_size = check_filesize(current_dir, upload_file_name, client) 673 | except res.ErrorResponse, e: 674 | print e 675 | raise 676 | # print "uploaded " + convert_bytes(upload_file_size) + " of " + convert_bytes(local_file_size) 677 | clearscreen() 678 | print_dir(access_token, user_id, current_dir) 679 | print "[+]\tsuccessfully uploaded " + upload_file_name 680 | 681 | # function to copy files 682 | def copy_file(client, old_file, new_file, current_dir): 683 | client.file_copy(current_dir + "/" + old_file, new_file) 684 | 685 | # function to backup files when they are being edited 686 | def backup_file(client, current_dir, file_to_edit): 687 | client.file_copy(current_dir + "/" + file_to_edit, current_dir + "/" + file_to_edit + ".backup") 688 | 689 | # download files to the ~/Downloads/RaspberryCloud folder by default (it will be created if it does not exist!) 690 | # can be changed if you supply a different destination as an argument 691 | def download_file(current_dir, file_to_download, client, download_loc=(expanduser("~") + "/Downloads/RasberryCloud")): 692 | # check and see if the path exists 693 | if not os.path.exists(download_loc): 694 | # tell the system to create it 695 | os.makedirs(download_loc) 696 | # create and open the file on the user's system that we will write to 697 | out = open(download_loc + "/" + file_to_download, 'w+') 698 | # actually download the file 699 | with client.get_file(current_dir + "/" + file_to_download) as f: 700 | out.write(f.read()) 701 | out.close() 702 | print JColor.BOLDON + JColor.FGYELLOW + "[+]\tsuccessfully downloaded " + + JColor.ENDC + JColor.BOLDOFF + JColor.FGGREEN + file_to_download + JColor.ENDC 703 | 704 | # i think you can guess what this does ;) 705 | curr_time = time.strftime('%H:%M:%S') 706 | 707 | # create a current directory variable to store which directory we are currently in 708 | # this will turn out to be very important for nearly all the other commands 709 | current_dir = "/" 710 | 711 | # start our main input loop 712 | while (1): 713 | # get the very first input, the program will loop back to this each 714 | # time the a conditional finishes executing 715 | handle_input = get_command() 716 | if handle_input == '! -h' or handle_input == '! --help': 717 | print """ 718 | ! ~ open raspberry cloud shell 719 | usage: ! 720 | example: ! 721 | optional arguments: 722 | -h, --help show this help message and exit 723 | note: this will open the shell only, to exit the shell type '!q' 724 | This shell is identical to the bash shell except you cannot 725 | change directories. 726 | special functionality: while inside the shell you can enter 'bash' for a full blown bash shell which can be exited by pressing CTRL+D 727 | """ 728 | elif '!' in handle_input: 729 | 730 | handle_input = handle_input.replace('!','') 731 | handle_input = handle_input.strip() 732 | os.system(handle_input) 733 | shell_mode = None 734 | print "\nWelcome to the bow shell! " 735 | print "Enter 'bash' to call a full-on system shell." 736 | print "From the bow shell enter '!q' to return to your Dropbox directory." 737 | print "From the bash shell press CTRL-D to return to the bow shell." 738 | while (1): 739 | # can enter shell instance with bash and exit back to the raspberry cloud with ctrl+d 740 | shell_mode = raw_input(JColor.STRKTHRUON + JColor.BOLDON + JColor.FGYELLOW + "|" + JColor.ENDC + JColor.BOLDOFF + JColor.STRKTHRUOFF + JColor.STRKTHRUON + JColor.BOLDON + JColor.FGYELLOW + "} " + JColor.ENDC + JColor.BOLDOFF + JColor.STRKTHRUOFF) + " " 741 | if shell_mode == "!q": 742 | break 743 | elif "bash" in shell_mode: 744 | print "\nenter CTRL + d to return to the Raspberry Cloud arrow shell" 745 | os.system(shell_mode) 746 | else: 747 | os.system(shell_mode) 748 | #handle_input = handle_input.split() 749 | # list_to_string = ' '.join(map(str, handle_input)) 750 | #list_pointer = 0 751 | #string_builder = '"' 752 | #while list_pointer <= len(handle_input) - 1: 753 | # string_builder = string_builder + handle_input[list_pointer] + '", "' 754 | # list_pointer += 1 755 | # print "looping" 756 | # string_builder2 = string_builder + ' "' 757 | 758 | #print 'new list' 759 | #print string_builder2 760 | # try: 761 | # call([string_builder2]) 762 | #except Exception as ex: 763 | # print ex 764 | # raise 765 | # in case someone enters the command with no parameters, give them some help 766 | elif handle_input == 'mkdir' or handle_input == 'mkdir -h' or handle_input == 'mkdir --help': 767 | print """ 768 | mkdir ~ create a new folder 769 | usage: mkdir absolue_path_to_folder 770 | example: mkdir /Pictures/Family 771 | optional arguments: 772 | -h, --help show this help message and exit 773 | """ 774 | elif ('mkdir' in handle_input) and ('-h' not in handle_input) and ('--help' not in handle_input): 775 | try: 776 | handle_input = handle_input.replace("mkdir","") 777 | handle_input = handle_input.strip('"') 778 | handle_input = handle_input.strip("'") 779 | handle_input = handle_input.strip(" ") 780 | client.file_create_folder(handle_input.strip()) 781 | clearscreen() 782 | print_dir(access_token, user_id, current_dir) 783 | print "Folder " + handle_input + " created successfully." 784 | except Exception as ex: 785 | error_img(str(ex)) 786 | # raise 787 | # list or refresh the files in current directory 788 | elif handle_input == 'ls -h' or handle_input == 'ls --help': 789 | print """ 790 | ls ~ print a list of files in the current directory 791 | usage: ls 792 | example: ls 793 | optional arguments: 794 | -h, --help show this help message and exit 795 | """ 796 | elif 'ls' in handle_input: 797 | clearscreen() 798 | try: 799 | print_dir(access_token, user_id, current_dir) 800 | except Exception as ex: 801 | error_img(str(ex)) 802 | # raise 803 | # go back to the root directory 804 | elif handle_input == 'cd': 805 | print_dir(access_token, user_id, "/") 806 | current_dir = "/" 807 | # change to another directory 808 | elif handle_input == 'cd -h' or handle_input == 'cd --help': 809 | print """ 810 | cd ~ change to another directory 811 | usage: cd directory_path_to_change_to 812 | example: cd /Pictures 813 | note: using cd by itslef will bring you back to the root directory 814 | optional arguments: 815 | -h, --help show this help message and exit 816 | """ 817 | elif 'cd' in handle_input: 818 | try: 819 | # scrub out what was entered in so we are left with only the argument to process 820 | handle_input = handle_input.replace("cd","") 821 | # strip away any whitespaces 822 | handle_input = handle_input.strip() 823 | clearscreen() 824 | # if we are in the root directory set the new directory to the root "/" + what was just entered 825 | # for example: cd work will change from the root or / to /work 826 | if current_dir == "/": 827 | current_dir = current_dir + handle_input 828 | # otherwise tack the newly entered directory onto the previous one so that we can get into nested folders 829 | else: 830 | current_dir = current_dir + "/" + handle_input 831 | 832 | print_dir(access_token, user_id, current_dir) 833 | #current_dir = handle_input 834 | #current_dir = current_dir + "/" + handle_input 835 | #get_command() 836 | except Exception as ex: 837 | current_dir = "/" 838 | # print_dir(access_token, user_id, "/") 839 | error_img(str(ex)) 840 | # raise 841 | # this is probably my favorite part of the whole program! 842 | # this function downloads the file to a temp folder, opens it in nano/emacs/vim 843 | # and when your finished editing it will automatically upload it back into 844 | # the same folder and deletes the old file fromthe temp folder 845 | elif handle_input == 'use' or handle_input == 'use -h' or handle_input == 'use --help': 846 | print """ 847 | use ~ use text editor of your choice to edit and save files inside your dropbox. text editor supplied must already be installed 848 | usage: use text_editor filename1 849 | example: use nano tps_reports.txt 850 | example 2: use emacs tps_reports.txt 851 | example 3: use vim tps_reports.txt 852 | optional arguments: 853 | -h, --help show this help message and exit 854 | """ 855 | elif 'use' in handle_input: 856 | temp_folder = "temp/" 857 | try: 858 | handle_input = handle_input.replace("use","") 859 | handle_input = handle_input.strip().split() 860 | 861 | file_path = temp_folder + handle_input[1] 862 | out = open(file_path, 'wb') 863 | file_open = True 864 | with client.get_file(current_dir + "/" + handle_input[1]) as f: 865 | out.write(f.read()) 866 | out.close() 867 | 868 | # backup the file 869 | backup_file(client, current_dir, handle_input[1]) 870 | # use a system call to access nano 871 | call([handle_input[0], file_path]) 872 | clearscreen() 873 | print "editing file..." 874 | print JColor.FGGREEN + "[+]\tsuccessfully edited " + JColor.ENDC + JColor.FGBLUE + handle_input[1] + JColor.ENDC 875 | sys.stdout.flush() 876 | # reupload the file 877 | print "uploading.." + current_dir 878 | sys.stdout.flush() 879 | f = open(file_path, 'rb') 880 | response = client.put_file(current_dir + "/" + handle_input[1], f, True) 881 | # delete the temp file 882 | print "cleaning up..." 883 | sys.stdout.flush() 884 | os.remove(file_path) 885 | client.file_delete(current_dir + "/" + handle_input[1] + ".backup") 886 | clearscreen() 887 | # other time formats 888 | # curr_time = time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime()) 889 | # curr_time = time.strftime("%H:%M:%S", time.gmtime()) 890 | 891 | print JColor.FGGREEN + "[+]\tsuccessfully uploaded " + JColor.ENDC + JColor.FGBLUE + handle_input[1] + JColor.ENDC + " to " + JColor.FGBLUE + current_dir + JColor.ENDC + " at " + JColor.FGWHITE + curr_time + JColor.ENDC 892 | print_dir(access_token, user_id, current_dir) 893 | 894 | 895 | except Exception as ex: 896 | error_img(str(ex)) 897 | # raise 898 | elif handle_input == 'cp' or handle_input == 'cp -h' or handle_input == 'cp --help': 899 | print """ 900 | cp ~ copy a file/folder from one location to another 901 | usage: cp absolute_path_to_file_with_filename new_path_to_file_with_filename 902 | example: cp /School/Essay.pdf /School/History/Essay.pdf 903 | note: if a different filename is given for the second arguement, the file will be copied and renamed 904 | optional arguments: 905 | -h, --help show this help message and exit 906 | """ 907 | elif 'cp' in handle_input: 908 | handle_input = handle_input.replace("cp","") 909 | handle_input = handle_input.split() 910 | try: 911 | # print handle_input[0] 912 | # print handle_input[1] 913 | client.file_copy(handle_input[0], handle_input[1]) 914 | print JColor.FGBLUE + handle_input[0] + JColor.ENDC + " was successfully copied to " + JColor.FGBLUE + handle_input[1] + JColor.ENDC + " at " + JColor.FGWHITE + curr_time + JColor.ENDC 915 | except Exception as ex: 916 | error_img(str(ex)) 917 | # print ex 918 | elif handle_input == 'mv' or handle_input == 'mv -h' or handle_input == 'mv --help': 919 | print """ 920 | mv ~ move a file/folder from one location to another 921 | usage: mv absolute_path_to_file_with_filename new_path_to_file_with_filename 922 | example: mv /Music/Playlist /Shared 923 | note: if a different filename is given for the second arguement, the file will be moved and renamed 924 | special usage: just like in linux, you may use this command to rename a file also. 925 | optional arguments: 926 | -h, --help show this help message and exit 927 | """ 928 | elif 'mv' in handle_input: 929 | handle_input = handle_input.replace("mv","").strip() 930 | handle_input = handle_input.split() 931 | formatted_time = format_time() 932 | try: 933 | client.file_move(handle_input[0], handle_input[1]) 934 | print JColor.FGBLUE + handle_input[0] + JColor.ENDC + " was successfully moved to " + JColor.FGBLUE + handle_input[1] + JColor.ENDC + " at " + JColor.FGWHITE + formatted_time + JColor.ENDC 935 | except Exception as ex: 936 | error_img(str(ex)) 937 | elif handle_input == 'rm' or handle_input == 'rm -h' or handle_input == 'rm --help': 938 | print """ 939 | rm ~ delete a file/folder 940 | usage: rm absolute_path_to_file_1 absolute_path_to_file_2 absolute_path_to_file_2 etc. 941 | example: rm /Random/Other /tps_report.txt 942 | optional arguments: 943 | -h, --help show this help message and exit 944 | """ 945 | elif 'rm' in handle_input: 946 | handle_input = handle_input.replace("rm","") 947 | handle_input = handle_input.split() 948 | list_pointer1 = 0 949 | list_pointer2 = 0 950 | list_to_string = ' '.join(map(str, handle_input)) 951 | delete_prompt = raw_input(JColor.FGRED + "WARNING: You are about to delete " + JColor.ENDC + JColor.FGBLUE + list_to_string + JColor.ENDC + JColor.FGRED + " forever! Proceed (Y/N)? " + JColor.ENDC) 952 | if (delete_prompt == 'Y') or (delete_prompt == 'y'): 953 | try: 954 | while list_pointer2 <= len(handle_input) - 1: 955 | client.file_delete(handle_input[list_pointer2]) 956 | list_pointer2 += 1 957 | clearscreen() 958 | print_dir(access_token, user_id, current_dir) 959 | if list_pointer2 > 1: 960 | print JColor.FGBLUE + list_to_string + JColor.ENDC + " were successfully deleted at " + JColor.FGWHITE + curr_time + JColor.ENDC 961 | else: 962 | print JColor.FGBLUE + list_to_string + JColor.ENDC + " was successfully deleted at " + JColor.FGWHITE + curr_time + JColor.ENDC 963 | except Exception as ex: 964 | error_img(str(ex) + '\nPlease make sure you entered the complete path.\nFor help enter' + JColor.FGORANGE + JColor.BOLDON + ' rm -h ' + JColor.ENDC + JColor.BOLDOFF) 965 | # raise 966 | elif (delete_prompt == 'N') or (delete_prompt == 'n'): 967 | clearscreen() 968 | print_dir(access_token, user_id, current_dir) 969 | else: 970 | clearscreen() 971 | print_dir(access_token, user_id, current_dir) 972 | elif handle_input == 'share' or handle_input == 'share -h' or handle_input == 'share --help': 973 | print """ 974 | share ~ create a link to share a file/folder 975 | usage: share absolute_path_to_file 976 | example: share /Art/ConceptArt 977 | optional arguments: 978 | -h, --help show this help message and exit 979 | """ 980 | elif 'share' in handle_input: 981 | handle_input = handle_input.replace("share","").strip() 982 | share_link = client.share(current_dir + "/" + handle_input, False) 983 | for a, b in share_link.iteritems(): 984 | if a == 'url': 985 | print "share link: " + b 986 | if a == 'expires': 987 | print "expires " + b 988 | elif handle_input == 'upload' or handle_input == 'upload -h' or handle_input == 'upload --help': 989 | print """ 990 | upload ~ upload a file to the current directory 991 | usage: upload path_to_local_file filename 992 | example: /home/user/Documents/BeejCGuide.pdf BeejCguide.pdf 993 | note: file can be drag and dropped from the local machine into the terminal window 994 | optional arguments: 995 | -h, --help show this help message and exit 996 | """ 997 | elif 'upload' in handle_input: 998 | handle_input = handle_input.replace("upload","") 999 | handle_input = handle_input.replace("'","").strip() 1000 | handle_input = handle_input.split() 1001 | new_upload(current_dir, handle_input[0], handle_input[1], client) 1002 | #upload_file(current_dir, handle_input[0], handle_input[1], client) 1003 | elif handle_input == 'dl' or handle_input == 'dl -h' or handle_input == 'dl --help' or handle_input == 'dl -c': 1004 | print """ 1005 | dl ~ download files from current directory 1006 | usage: dl filename1 filename2 filename3 filename4 etc. 1007 | example: dl tps_reports.txt intro_to_c.pdf 1008 | optional arguments: 1009 | -c, --compress convert file/folder to .zip and download (this is the only way to download entire folders) 1010 | -h, --help show this help message and exit 1011 | """ 1012 | elif ('dl' in handle_input) and ('-c' not in handle_input): 1013 | handle_input = handle_input.replace("dl","") 1014 | handle_input = handle_input.replace("'","") 1015 | handle_input = handle_input.replace('"',"").strip() 1016 | handle_input = handle_input.split() 1017 | list_pointer = 0 1018 | while list_pointer <= len(handle_input) - 1: 1019 | try: 1020 | download_file(current_dir, handle_input[list_pointer], client) 1021 | except Exception as ex: 1022 | error_img(str(ex)) 1023 | # print "If it's a folder use the -f flag dl -f etc.!" 1024 | # raise 1025 | list_pointer += 1 1026 | 1027 | # TODO this still doesn't work 1028 | # wget -r -l1 --directory-prefix=~/Downloads/RaspberryCloud --no-parent -A zip "https://www.dropbox.com/sh/pz5zqn72a5ct6om/AACLQJRZiNYMHGYpL6YDJKGqa?dl=1" 1029 | # http://stackoverflow.com/questions/6533187/wget-removing-filename-since-it-should-be-rejected 1030 | 1031 | # make an option for downloading folders 1032 | elif 'dl -c' in handle_input: 1033 | # dl entire folder 1034 | handle_input = handle_input.replace("dl -c","") 1035 | handle_input = handle_input.replace("'","") 1036 | handle_input = handle_input.replace('"',"") 1037 | handle_input = handle_input.strip() 1038 | handle_input = handle_input.split(" ") 1039 | # handle_input = map(str.strip, handle_input) 1040 | list_to_string = ' '.join(map(str, handle_input)) 1041 | list_pointer_dlf = 0 1042 | while list_pointer_dlf <= len(handle_input) - 1: 1043 | try: 1044 | if current_dir == "/": 1045 | share_link = client.share(current_dir + handle_input[list_pointer_dlf], False) 1046 | else: 1047 | share_link = client.share(current_dir + "/" + handle_input[list_pointer_dlf], False) 1048 | for a, b in share_link.iteritems(): 1049 | if a == 'url': 1050 | link_address = b 1051 | # check and see if the path exists 1052 | home = expanduser("~") 1053 | download_loc = home + '/Downloads/RaspberryCloud' + '/' 1054 | if not os.path.exists(download_loc): 1055 | # tell the system to create it 1056 | os.makedirs(download_loc) 1057 | # os.system('curl ' + link_address + '?dl=1 --create-dirs -o ' + home + '/Downloads/RaspberryCloud' + '/' + handle_input[0].strip("/") + ".zip") 1058 | os.system('wget -E -H -K --force-directories -O ' + home + '/Downloads/RaspberryCloud' + '/' + handle_input[list_pointer_dlf].strip("/") + ".zip " + link_address + "?dl=1") 1059 | sys.stdout.flush() 1060 | list_pointer_dlf += 1 1061 | # download_file(current_dir, handle_input[list_pointer], client) 1062 | print JColor.FGGREEN2 + 'Successfully downloaded ' + JColor.ENDC + JColor.FGBLUE + list_to_string + JColor.ENDC + ' to ' + home + '/Downloads/RaspberryCloud' 1063 | # JaredColors.Successfully downloaded ' + JColor.ENDC + JColor.FGBLUE + list_to_string + JColor.ENDC + ' to ' + home + '/Downloads/RaspberryCloud' 1064 | except Exception as ex: 1065 | error_img(str(ex)) 1066 | # raise 1067 | # raise 1068 | clearscreen() 1069 | print_dir(access_token, user_id, current_dir) 1070 | print '[+]\t' + JColor.FGGREEN2 + 'Successfully downloaded ' + JColor.ENDC + JColor.FGBLUE + list_to_string + JColor.ENDC + ' to ' + home + '/Downloads/RaspberryCloud' 1071 | # list_pointer_dlf += 1 1072 | #share_link = client.share(current_dir + "/" + handle_input) 1073 | elif handle_input == 'view' or handle_input == 'view -h' or handle_input == 'view --help': 1074 | print """ 1075 | view ~ view img as thumbnail 1076 | usage: view imagename preview_size 1077 | example: view glamour_shot_by_deb.jpg 1078 | optional arguments: 1079 | -h, --help show this help message and exit 1080 | note: If no image size is entered, the preview will default 1081 | to medium size (128x128). Also, image sizes are displayed 1082 | approximately as follows: 1083 | "xs" (32x32) 1084 | "s" (64x64) 1085 | "m" (128x128) 1086 | "l" (640x480) 1087 | "xl" (1024x768) 1088 | """ 1089 | elif 'view' in handle_input: 1090 | handle_input = handle_input.replace('view','') 1091 | handle_input = handle_input.replace('/', '') 1092 | handle_input = handle_input.split() 1093 | home = expanduser("~") 1094 | download_loc = home + '/Downloads/RaspberryCloud' 1095 | if current_dir == '/': 1096 | use_dir = current_dir + handle_input[0] 1097 | else: 1098 | use_dir = current_dir + '/' + handle_input[0] 1099 | if len(handle_input) > 1: 1100 | try: 1101 | picture_type = 'JPEG' 1102 | file_to_download = client.thumbnail(use_dir, handle_input[1]) 1103 | except Exception as ex: 1104 | error_img(str(ex)) 1105 | else: 1106 | try: 1107 | picture_type = 'JPEG' 1108 | file_to_download = client.thumbnail(use_dir, 'm') 1109 | except Exception as ex: 1110 | error_img(str(ex)) 1111 | try: 1112 | temp_path = "temp/" + 'thumbnail' 1113 | out = open(temp_path, 'w+') 1114 | f = file_to_download 1115 | out.write(f.read()) 1116 | # TODO add colors 1117 | out.close() 1118 | # test to make sure the file isn't empty 1119 | if os.stat(temp_path).st_size == 0: 1120 | # error_img('Cannot preview thumbnail.\nMake sure it is a picture file and not over 20MB.') 1121 | os.remove(temp_path) 1122 | else: 1123 | os.system('gpicview ' + temp_path) 1124 | os.remove(temp_path) 1125 | except Exception as ex: 1126 | pass 1127 | # error_img(str(ex)) 1128 | # raise 1129 | #print "[+]\tsuccessfully downloaded " + file_to_download 1130 | elif handle_input == 'clear -h' or handle_input == 'clear --help': 1131 | print """ 1132 | clear ~ clear the screen 1133 | usage: clear 1134 | example: clear 1135 | optional arguments: 1136 | -h, --help show this help message and exit 1137 | """ 1138 | elif 'clear' in handle_input: 1139 | os.system('clear') 1140 | elif handle_input == 'fs' or handle_input == 'fs -h' or handle_input == 'fs --help': 1141 | print """ 1142 | fs ~ check size of file 1143 | usage: fs filename 1144 | example: fs tps_reports.txt 1145 | note: does not work on folders 1146 | optional arguments: 1147 | -h, --help show this help message and exit 1148 | """ 1149 | elif 'fs' in handle_input: 1150 | handle_input = handle_input.replace("fs","") 1151 | handle_input = handle_input.replace("'","") 1152 | handle_input = handle_input.replace('"',"").strip() 1153 | try: 1154 | check_filesize(current_dir, handle_input, client) 1155 | except Exception as ex: 1156 | error_img(str(ex)) 1157 | elif handle_input == 'mlink' or handle_input == 'mlink -h' or handle_input == 'mlink --help': 1158 | print """ 1159 | mlink ~ create a media link to an image/video/sound file from your Dropbox 1160 | usage: mlink absolute_path_to_file 1161 | example: mlink /Videos/important_video.mov 1162 | optional arguments: 1163 | -h, --help show this help message and exit 1164 | """ 1165 | elif 'mlink' in handle_input: 1166 | handle_input = handle_input.replace("mlink", "").strip() 1167 | try: 1168 | media_link = client.media(current_dir + "/" + handle_input) 1169 | for a, b in media_link.iteritems(): 1170 | if a == 'url': 1171 | print "share link: " + b 1172 | if a == 'expires': 1173 | print "expires " + b 1174 | except Exception as ex: 1175 | error_img(str(ex)) 1176 | elif handle_input == 'home -h' or handle_input == 'home --help': 1177 | print """ 1178 | home ~ return to the home screen of Raspberry Cloud 1179 | usage: home 1180 | example: home 1181 | optional arguments: 1182 | -h, --help show this help message and exit 1183 | """ 1184 | elif handle_input == 'home': 1185 | clearscreen() 1186 | home_screen(nickname) 1187 | elif handle_input == '?': 1188 | # print the entire help screen 1189 | print JColor.FGWHITE + JColor.BOLDON + """ 1190 | ____ ____ ____ ____ ____ ____ ____ 1191 | ||c ||||o ||||m ||||a ||||n ||||d ||||s || 1192 | ||__||||__||||__||||__||||__||||__||||__|| 1193 | |/__\||/__\||/__\||/__\||/__\||/__\||/__\| 1194 | 1195 | """ + JColor.ENDC + """mkdir ~ create a new folder 1196 | usage: mkdir absolue_path_to_folder 1197 | example: mkdir /Pictures/Family 1198 | optional arguments: 1199 | -h, --help show this help message and exit 1200 | 1201 | rm ~ delete a file/folder 1202 | usage: rm absolute_path_to_file_1 absolute_path_to_file_2 absolute_path_to_file_2 etc. 1203 | example: rm /Random/Other /tps_report.txt 1204 | optional arguments: 1205 | -h, --help show this help message and exit 1206 | 1207 | ls ~ print a list of files in the current directory 1208 | usage: ls 1209 | example: ls 1210 | optional arguments: 1211 | -h, --help show this help message and exit 1212 | 1213 | cd ~ change to another directory 1214 | usage: cd directory_path_to_change_to 1215 | example: cd /Pictures 1216 | note: using cd by itslef will bring you back to the root directory 1217 | optional arguments: 1218 | -h, --help show this help message and exit 1219 | 1220 | cp ~ copy a file/folder from one location to another 1221 | usage: cp absolute_path_to_file_with_filename new_path_to_file_with_filename 1222 | example: cp /School/Essay.pdf /School/History/Essay.pdf 1223 | note: if a different filename is given for the second arguement, the file will be copied and renamed 1224 | optional arguments: 1225 | -h, --help show this help message and exit 1226 | 1227 | mv ~ move a file/folder from one location to another 1228 | usage: mv absolute_path_to_file_with_filename new_path_to_file_with_filename 1229 | example: mv /Music/Playlist /Shared 1230 | note: if a different filename is given for the second arguement, the file will be moved and renamed 1231 | special usage: just like in linux, you may use this command to rename a file also. 1232 | optional arguments: 1233 | -h, --help show this help message and exit 1234 | 1235 | mlink ~ create a media link to an image/video/sound file from your Dropbox 1236 | usage: mlink absolute_path_to_file 1237 | example: mlink /Videos/important_video.mov 1238 | optional arguments: 1239 | -h, --help show this help message and exit 1240 | 1241 | share ~ create a link to share a file/folder 1242 | usage: share absolute_path_to_file 1243 | example: share /Art/ConceptArt 1244 | optional arguments: 1245 | -h, --help show this help message and exit 1246 | 1247 | upload ~ upload a file to the current directory 1248 | usage: upload path_to_local_file filename 1249 | example: /home/user/Documents/BeejCGuide.pdf BeejCguide.pdf 1250 | note: file can be drag and dropped from the local machine into the terminal window 1251 | optional arguments: 1252 | -h, --help show this help message and exit 1253 | 1254 | dl ~ download files from current directory 1255 | usage: dl filename1 filename2 filename3 filename4 etc. 1256 | example: dl tps_reports.txt intro_to_c.pdf 1257 | optional arguments: 1258 | -c, --compress convert file/folder to .zip and download (this is the only way to download entire folders) 1259 | -h, --help show this help message and exit 1260 | 1261 | fs ~ check size of file 1262 | usage: fs filename 1263 | example: fs tps_reports.txt 1264 | note: does not work on folders 1265 | optional arguments: 1266 | -h, --help show this help message and exit 1267 | 1268 | use ~ use text editor of your choice to edit and save files inside your dropbox. text editor supplied must already be installed 1269 | usage: use text_editor filename1 1270 | example: use nano tps_reports.txt 1271 | example 2: use emacs tps_reports.txt 1272 | example 3: use vim tps_reports.txt 1273 | optional arguments: 1274 | -h, --help show this help message and exit 1275 | 1276 | time ~ print the current time and date 1277 | usage: time 1278 | example: time 1279 | optional arguments: 1280 | -h, --help show this help message and exit 1281 | 1282 | ! ~ open raspberry cloud shell 1283 | usage: ! 1284 | example: ! 1285 | optional arguments: 1286 | -h, --help show this help message and exit 1287 | note: This will open the shell only, to exit the shell type '!q' 1288 | This shell is identical to the bash shell except you cannot 1289 | change directories. 1290 | special functionality: while inside the shell you can enter 'bash' for a full blown bash shell which can be exited by pressing CTRL+D 1291 | 1292 | view ~ view img as thumbnail 1293 | usage: view imagename preview_size 1294 | example: view glamour_shot_by_deb.jpg 1295 | optional arguments: 1296 | -h, --help show this help message and exit 1297 | note: If no image size is entered, the preview will default 1298 | to medium size (128x128). Also, image sizes are displayed 1299 | approximately as follows: 1300 | "xs" (32x32) 1301 | "s" (64x64) 1302 | "m" (128x128) 1303 | "l" (640x480) 1304 | "xl" (1024x768) 1305 | 1306 | clear ~ clear the screen 1307 | usage: clear 1308 | example: clear 1309 | optional arguments: 1310 | -h, --help show this help message and exit 1311 | 1312 | home ~ return to the home screen of Raspberry Cloud 1313 | usage: home 1314 | example: home 1315 | optional arguments: 1316 | -h, --help show this help message and exit 1317 | 1318 | ? ~ view the entire list of commands 1319 | useage: ? 1320 | example: ? 1321 | optional arguments: 1322 | -h, --help show this help message and exit 1323 | note: Can't be used from within the Raspberry Cloud shell or bash shell. 1324 | 1325 | l ~ logout and quit raspberry cloud 1326 | usage: l 1327 | example: l 1328 | optional arguments: 1329 | -h, --help show this help message and exit 1330 | note: Can't be used from within the Raspberry Cloud shell or bash shell. 1331 | """ 1332 | elif handle_input == 'time -h' or handle_input == 'time --help': 1333 | print """ 1334 | time ~ print the current time and date 1335 | usage: time 1336 | example: time 1337 | optional arguments: 1338 | -h, --help show this help message and exit 1339 | """ 1340 | elif handle_input == 'time': 1341 | formatted_date = format_date(True) 1342 | print formatted_date 1343 | # print time.strftime("%d-%m-%Y, %H:%M:%S") 1344 | elif handle_input == 'l -h' or handle_input == 'l --help': 1345 | print """ 1346 | l ~ logout and quit raspberry cloud 1347 | usage: l 1348 | example: l 1349 | optional arguments: 1350 | -h, --help show this help message and exit 1351 | note: Can't be used from within the Raspberry Cloud shell or bash shell. 1352 | """ 1353 | elif handle_input == 'l': 1354 | # clearscreen() 1355 | logout_prompt = raw_input("Are you sure you want to logout (Y/N)? ") 1356 | if (logout_prompt == 'Y') or (logout_prompt == 'y'): 1357 | clearscreen() 1358 | sys.exit() 1359 | elif (logout_prompt == 'N') or (logout_prompt == 'n'): 1360 | clearscreen() 1361 | print_dir(access_token, user_id, current_dir) 1362 | else: 1363 | clearscreen() 1364 | print_dir(access_token, user_id, current_dir) 1365 | else: 1366 | print "Please enter a valid command.\nEnter " + JColor.FGORANGE + JColor.BOLDON + "?" + JColor.ENDC + JColor.BOLDOFF + " to view a list of commands." 1367 | 1368 | # load in config file and check to see if this is the 1369 | # first run of the program 1370 | settings = ConfigParser.ConfigParser() 1371 | f = open("config.ini","r") 1372 | settings.readfp(f) 1373 | first_run = settings.get('FirstRun', 'first_run') 1374 | 1375 | if (first_run == 'True'): 1376 | 1377 | clearscreen() 1378 | 1379 | # a = settings.get('AppKey', 'app_key').strip() 1380 | # b = settings.get('AppSecret', 'app_secret').strip() 1381 | 1382 | appkey = raw_input(JColor.BOLDON + JColor.FGCYAN + "Please head over to https://www.dropbox.com/developers/apps \n and create a new App. \nMake it a Core app, give it any name that you like. \n Make sure it has full access to Dropbox. \n Once it has been created enter the App Key and App Secret below." + JColor.ENDC + JColor.BOLDOFF + JColor.BOLDON + JColor.FGYELLOW +" \n\nApp Key: " + JColor.ENDC + JColor.BOLDOFF).strip() 1383 | appsecret = raw_input(JColor.BOLDON + JColor.FGYELLOW + "App Secret: " + JColor.ENDC + JColor.BOLDOFF).strip() 1384 | #try: 1385 | flow = dropbox.client.DropboxOAuth2FlowNoRedirect(appkey, appsecret) 1386 | authorize_url = flow.start() 1387 | #except Exception as ex: 1388 | # error_img(str(ex)) 1389 | 1390 | # get user's nickname 1391 | nickname = raw_input(JColor.BOLDON + JColor.FGCYAN + "What should I call you? " + JColor.ENDC + JColor.BOLDOFF).strip() 1392 | 1393 | clearscreen() 1394 | # make sure its converted to a string 1395 | nickname = str(nickname) 1396 | # settings.set('AccessCode', 'access_code', access_token) 1397 | 1398 | home_screen(nickname, False) 1399 | auto_or_manual = raw_input(JColor.FGYELLOW + JColor.BOLDON + "\n*Please head over to " + authorize_url + " \n(1) Entering \'g\' to open your web browser \n(2) Entering \'m\' to open it manually \nNOTE: Once there click 'Allow' and copy the code back into this window (you may be required to login first).\n" + JColor.ENDC + JColor.BOLDOFF + JColor.BOLDON + JColor.FGCYAN + "\n>> " + JColor.ENDC + JColor.BOLDOFF) 1400 | # auto_or_manual = raw_input('Welcome to Raspberry Cloud!\nHead over to ' + authorize_url + ' to confirm your account either by:\n(1) Entering \'g\' to open your web browser \n(2) Entering \'m\' to open it manually \nNOTE: Once there click "Allow" and copy the code back into this window(you may be required to login first).\n>> ') 1401 | 1402 | if auto_or_manual == 'g': 1403 | webbrowser.open(authorize_url) 1404 | elif auto_or_manual == 'm': 1405 | pass 1406 | #print '1. Go to: ' + authorize_url 1407 | #print '2. Click "Allow" (you might have to log in first)' 1408 | #print '3. Copy the authorization code.' 1409 | code = raw_input(JColor.BOLDON + JColor.FGCYAN + "Enter the authorization code here: " + JColor.ENDC + JColor.BOLDOFF).strip() 1410 | 1411 | try: 1412 | # This will fail if the user enters an invalid authorization code 1413 | access_token, user_id = flow.finish(code) 1414 | # add access code to file and change first_run variable to false 1415 | # so we won't have to repeat this process next time! 1416 | settings.set('FirstRun', 'first_run', 'False') 1417 | settings.set('AccessCode', 'access_code', access_token) 1418 | settings.set('NickName', 'nick_name', nickname) 1419 | f = open("config.ini","w") 1420 | settings.write(f) 1421 | f.close() 1422 | 1423 | access_dropbox(access_token, user_id) 1424 | except Exception as ex: 1425 | error_img(str(ex)) 1426 | # raise 1427 | 1428 | clearscreen() 1429 | elif first_run == 'False': 1430 | #access_token = raw_input("enter token: ").strip() 1431 | access_token = settings.get('AccessCode', 'access_code').strip() 1432 | user_id = access_token.strip() 1433 | 1434 | #print access_token 1435 | #user_id = settings.get('AccessCode', 'access_code').strip() 1436 | access_dropbox(access_token, user_id) 1437 | 1438 | # more curses stuff 1439 | # set colors 1440 | # get width, heigth of the screen, etc. 1441 | def main(): 1442 | screen = init_curses() 1443 | y, x = screen.getmaxyx() 1444 | # create green 1445 | curses.init_pair(1, curses.COLOR_GREEN, -1) 1446 | # create red 1447 | curses.init_pair(2, curses.COLOR_RED, -1) # -1 is default bcgd color 1448 | # create white 1449 | curses.init_pair(3, curses.COLOR_WHITE, -1) 1450 | # create cyan 1451 | curses.init_pair(4, curses.COLOR_CYAN, -1) 1452 | # create yellow 1453 | curses.init_pair(5, curses.COLOR_YELLOW, -1) 1454 | # create black on white 1455 | curses.init_pair(6, curses.COLOR_BLACK, curses.COLOR_WHITE) 1456 | # print the splash screen out! 1457 | splash_screen(screen, y, x) 1458 | 1459 | 1460 | # check and see if this program is being run by itself 1461 | # if so call the main function 1462 | if __name__ == '__main__': 1463 | main() 1464 | --------------------------------------------------------------------------------