def restart(self): lista = [ 'netcontrol', 'apache2', 'bind9', 'postfix', 'courier-authdaemon', 'courier-imap', 'courier-imap-ssl', 'courier-ldap', 'courier-pop' ] for i in lista: restart("/etc/init.d/%s restart" % i, "True") return True
def on_submit(self, event, params, vars=None): if params[0] == 'sshd': if vars.getvalue('action', '') == 'salvar_config': self._texto = vars.getvalue('texto', 'none') open('/etc/ssh/sshd_config', 'w').write(self._texto) self._editing = 'salvo' if vars.getvalue('action', '') == 'restart_ssh': restart('/etc/init.d/ssh restart', "True") #process = subprocess.Popen("/etc/init.d/ssh restart", shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) #self._resposta = process.communicate() self._resposta = "SSH reiniciado com sucesso" self._editing = 'restart' if vars.getvalue('action', '') == 'OK': self._editing = None
def on_submit(self, event, params, vars = None): if params[0] == 'sshd': if vars.getvalue('action','') == 'salvar_config': self._texto = vars.getvalue('texto','none') open('/etc/ssh/sshd_config','w').write(self._texto) self._editing = 'salvo' if vars.getvalue('action','') == 'restart_ssh': restart('/etc/init.d/ssh restart',"True") #process = subprocess.Popen("/etc/init.d/ssh restart", shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) #self._resposta = process.communicate() self._resposta = "SSH reiniciado com sucesso" self._editing = 'restart' if vars.getvalue('action','') == 'OK': self._editing = None
def restart(): print("REMEMBER IF NOTHING YOU TYPE WORKS, TYPE 'M'.") element = str( input(''' Are you sure you want to restart?" This will delete all your data." If yes, type -> 'restart', if no, type -> 'n' ''')) if element == 'restart': for each in textfile_array: write_file(each, '') print('''Hey, this program has been restarted like you wanted. I need some data to make a plan for you.\n''') # If there is no start date, the program can't do calculations. This is why we add the current date as the start date if len(list_file_data('start_date.txt')) == 0: # object today created containing information about date today = datetime.datetime.now() # writes this data to a file "start_date.txt" write_file('start_date.txt', str(today.year)) append_file('start_date.txt', str(today.month)) append_file('start_date.txt', str(today.day)) # Makes sure that name.txt is empty. If it is empty, it asks for a new name and writes it in "name.txt" if len(list_file_data('name.txt')) == 0: element = input("What would you like me to call you? ") # Checks for expected data type. if data_type(element, str) and any(c.isalpha() for c in element): write_file('name.txt', str(element)) print("I will now call you " + read_file('name.txt') + ".\n") else: print("Looks like you didn't give me the input I needed. ") restart() # If empty, put 0 as first element in these lists element = ['today_expenditure.txt', 'excess.txt', 'deficient.txt'] for i in element: if len(list_file_data(i)) == 0: write_file(i, 0)
def on_click(self, event, params, vars = None): if vars.getvalue('action','') == 'msg': a = open("/usr/share/proftpd/templates/welcome.msg").read() self._editing = "boas_vindas" self._msg = a elif vars.getvalue('action','') == 'libUsers': a = open("/etc/ftpusers",'w') a.write('# /etc/ftpusers: list of users disallowed ftp access. See ftpusers(5).\n\n') a.close() restart("/etc/init.d/proftpd restart", True) self._resposta = "ProFTPD reiniciado com sucesso" self._editing = "restart" elif vars.getvalue('action','') == 'blockUsers': a = open('/etc/ftpusers','w') a.write('# /etc/ftpusers: list of users disallowed ftp access. See ftpusers(5).\n\n') for i in vars.list[1:]: name, value = i.name, int(i.value) a.write( str( name + '\n' ) ) for i in open('/etc/passwd').readlines(): i = i.split(':') if int(i[2]) < 1000 and i[0] <> 'root': a.write(i[0]+'\n') a.close() restart("/etc/init.d/proftpd restart","True") self._resposta = "ProFTPD reiniciado com sucesso" self._editing = "restart" elif params[0] == 'box': a = open('/etc/ftpusers','w') a.write('# /etc/ftpusers: list of users disallowed ftp access. See ftpusers(5).\n\n') for i in vars.list[1:]: name, value = i.name, int(i.value) if value == 0: a.write( str( name + '\n' ) ) for i in open('/etc/passwd').readlines(): i = i.split(':') if int(i[2]) < 1000 and i[0] <> 'root': a.write(i[0]+'\n') a.close() restart("/etc/init.d/proftpd restart","True") self._resposta = "ProFTPD reiniciado com sucesso" self._editing = "restart" elif params[0] == "msg_user": if vars.getvalue('action','') == 'OK': a = open("/usr/share/proftpd/templates/welcome.msg","w") a.write(str(vars.getvalue('texto','none'))) self._editing = None
def restart(self): lista = ['netcontrol','apache2','bind9','postfix','courier-authdaemon','courier-imap','courier-imap-ssl','courier-ldap','courier-pop'] for i in lista: restart("/etc/init.d/%s restart"%i,"True") return True