Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8 -*-
- #
- # Copyright 2010 systemoveride <system_overide@live.it>
- #
- # This program is free software; you can redistribute it and/or modify
- # it under the terms of the GNU General Public License as published by
- # the Free Software Foundation; either version 2 of the License, or
- # (at your option) any later version.
- #
- # This program is distributed in the hope that it will be useful,
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- # GNU General Public License for more details.
- #
- # You should have received a copy of the GNU General Public License
- # along with this program; if not, write to the Free Software
- # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- # MA 02110-1301, USA.
- #
- import os
- import ftplib
- #INIZIO CLASSE COLORI
- #$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
- class color:
- PINK = '\033[95m'
- BLUE = '\033[94m'
- GREEN = '\033[92m'
- YELLOW = '\033[93m'
- RED = '\033[91m'
- END = '\033[0m'
- def disable(self):
- self.PINK = ''
- self.BLUE = ''
- self.GREEN = ''
- self.YELLOW = ''
- self.RED = ''
- self.END = ''
- def blue(word) :
- print color.BLUE + word + color.END
- def pink(word) :
- print color.PINK + word + color.END
- def green(word) :
- print color.GREEN + word + color.END
- def yellow(word) :
- print color.YELLOW + word + color.END
- def red(word) :
- print color.RED + word + color.END
- #FINE CLASSE CLORI
- #$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
- #INIZIO COMANDI DI SISTEMA
- #####################################################################################################
- def menucmd():
- print 'Sei nei comandi di sistema\n'
- blue('[1]Vedi utilizzo RAM\n')
- blue('[2]Vedi utilizzo spazio\n')
- blue('[3]Vedi processi\n')
- blue('[4]Vedi interfaccia di rete\n')
- blue('[5]Riavvia la rete\n')
- blue('[6]Aggiorna pacchetti sistema\n')
- blue('[7]Installa pacchetto\n')
- blue('[8]Mostra opzioni\n')
- blue('[9]Torna indietro\n')
- blue('[0]Esci')
- while 1:
- cmds=raw_input("\nCommand: \n")
- if cmds=="1":
- showram()
- elif cmds=="2":
- showspace()
- elif cmds=="3":
- processctrl()
- elif cmds=="4":
- netinterface()
- elif cmds=="5":
- netrestart()
- elif cmds=="6":
- update()
- elif cmds=="7":
- install()
- elif cmds=="8":
- yellow('Sei nei comandi di sistema\n')
- blue('[1]Vedi utilizzo RAM\n')
- blue('[2]Vedi utilizzo spazio\n')
- blue('[3]Vedi processi\n')
- blue('[4]Vedi interfaccia di rete\n')
- blue('[5]Riavvia la rete\n')
- blue('[6]Aggiorna pacchetti sistema\n')
- blue('[7]Installa pacchetto\n')
- blue('[8]Mostra opzioni\n')
- blue('[9]Torna indietro\n')
- blue('[0]Esci')
- elif cmds=="9":
- menug()
- elif cmds=="0":
- exit()
- else:
- red('Command error')
- def showram():
- command="free -m"
- os.system(command)
- def showspace():
- command="df -h"
- os.system(command)
- def processctrl():
- command="top"
- os.system(command)
- KeyboardInterrupt
- def netinterface():
- command="ifconfig"
- os.system(command)
- def netrestart():
- command="/etc/init.d/networking restart"
- os.system(command)
- def update():
- command="apt-get update && apt-get upgrade"
- os.system(command)
- def install():
- i=raw_input("Inserisci il nome del pacchetto da installare\n")
- command="apt-get install "+i
- os.system(command)
- #FINE COMANDI DI SISTEMA
- #####################################################################################################
- #INIZIO COMANDI FTP
- #||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
- def ftp():
- host=raw_input("Insert Host: \n")
- user=raw_input("Insert User: \n")
- pwd=raw_input("Insert Password: \n")
- ftp=ftplib.FTP()
- ftp.connect(host,21)
- if ftp.login(user, pwd):
- yellow('Connect!\n')
- ftp.retrlines('LIST')
- yellow('Sei nella Gestione FTP')
- blue('[1]Mostra file\n')
- blue('[2]New Directory\n')
- blue('[3]Upload File\n')
- blue('[4]Download File\n')
- blue('[5]Cancella File\n')
- blue('[6]Cancella Directory\n')
- blue('[7]Crea directory\n')
- blue('[8]Rinomina file\n')
- blue('[9]Mostra Opzioni\n')
- blue('[0]Disconnect\n')
- else:
- print "Connect Error.\n"
- blue('[1]Mostra file\n')
- blue('[2]New Directory\n')
- blue('[3]Upload File\n')
- blue('[4]Download File\n')
- blue('[5]Cancella File\n')
- blue('[6]Cancella Directory\n')
- blue('[7]Crea directory\n')
- blue('[8]Rinomina file\n')
- blue('[9]Mostra Opzioni\n')
- blue('[0]Disconnect\n')
- while 1:
- cmftp=raw_input(color.YELLOW+user+'@'+host+'~#: '+color.END)
- if cmftp=="2":
- ct=raw_input("Percorso directory: \n")
- try:
- ftp.cwd(ct)
- print "Succes!"
- except:
- red('Directory not found')
- elif cmftp=="1":
- ftp.retrlines('LIST')
- elif cmftp=="3":
- try:
- fil=raw_input("Path del file: \n")
- filefull = os.path.split(fil)[1]
- file = open(fil,'rb')
- ftp.storbinary('STOR ' + filefull, file)
- file.close()
- print "Uploades Successfull!"
- except:
- red('Upload Failed')
- elif cmftp=="4":
- pt=raw_input("Inserisci la path dove scaricare il file:\n")
- fl2=raw_input("Inserisci il nome del file:\n")
- try:
- os.chdir(pt)
- output=open(fl2, 'wb')
- ftp.retrbinary("RETR " + fl2, output.write)
- output.close()
- print "File "+fl2+" scaricato nella cartella "+pt
- except:
- red('Download Error!')
- elif cmftp=="5":
- kill=raw_input("File da eliminare:\n")
- try:
- ftp.delete(kill)
- print "File "+kill+" eliminato."
- except:
- red('Removal Failed')
- elif cmftp=="6":
- di=raw_input("Inserisci la direcotry da eliminare:\n")
- try:
- ftp.rmd(di)
- print "Directory "+di+" eliminata."
- except:
- red('Delete Error')
- elif cmftp=="7":
- mk=raw_input("Nome della directory da creare:\n")
- try:
- ftp.mkd(mk)
- print "Creata directory con il nome "+k
- except:
- red('Error directory creation')
- elif cmftp=="8":
- fr=raw_input("File da rinominare:\n")
- nm=raw_input("Nuovo nome:\n")
- try:
- ftp.rename(fr, nm)
- print "File "+fr+" rinominato in "+nm
- except:
- red('Rename Error')
- elif cmftp=="9":
- yellow('Comandi FTP')
- blue('[1]Mostra file\n')
- blue('[2]New Directory\n')
- blue('[3]Upload File\n')
- blue('[4]Download File\n')
- blue('[5]Cancella File\n')
- blue('[6]Cancella Directory\n')
- blue('[7]Crea directory\n')
- blue('[8]Rinomina file\n')
- blue('[9]Mostra Opzioni\n')
- blue('[0]Disconnect\n')
- elif cmftp=="0":
- ftp.close()
- print "Disconnect"
- menug()
- else:
- red('Command Error')
- #FINE COMANDI FTP
- #||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
- #MENU GENERALE
- #""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- def menug():
- yellow('OService\n')
- blue('[1]Utilità di sistema\n')
- blue('[2]Servizi\n')
- blue('[0]Uscita')
- while 1:
- cmd=raw_input("\nCommand: \n")
- if cmd=="1":
- menucmd()
- break
- elif cmd=="2":
- service()
- break
- elif cmd=="0":
- exit()
- else:
- red('Command error')
- def service():
- yellow('Servizi disponibili:\n')
- blue('[1]ftp\n')
- blue('[0]Indietro')
- chose=raw_input("Command: \n")
- if chose=="1":
- ftp()
- elif chose=="0":
- menug()
- else:
- red('Command Error')
- #FINE MENU GENERALE
- #""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- #MAIN PROGRAMMA
- #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- if os.getuid() == 0:
- menug()
- else:
- print "Eseguire l'accesso root per utilizzare tutte le funzioni\n"
- #FINE MAIN PROGRAMMA
- #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement