Código:
Traceback (most recent call last):
File "cmd_main.py", line 49, in <module>
maincmd()
File "cmd_main.py", line 28, in maincmd
date(cmd_input)
TypeError: an integer is required (got type str)
No se que rompi, solo dejo de funcionar derrepente...File "cmd_main.py", line 49, in <module>
maincmd()
File "cmd_main.py", line 28, in maincmd
date(cmd_input)
TypeError: an integer is required (got type str)
Aca el codigo del cmd_main.py
Código
y el codigo del date_cmd.py:
#!/usr/bin/python3 # -*- coding: utf-8 -*- import platform import sys from boot import * from commands import * from panic import * from dir_cmd import * from date_cmd import * from mkdir import * global machine_name machine_name = platform.node() def maincmd(): while True: cmd_input = input("[%s]$~ " % machine_name) if "println" in cmd_input: println(cmd_input) elif "clear" in cmd_input: clear() maincmd() elif "date" in cmd_input: date(cmd_input) elif "machine_info" in cmd_input: machine_info() elif "panic" in cmd_input: panic("ran_out_mem") elif "dr" in cmd_input: dr(cmd_input) elif "mkdir" in cmd_input: mkdir(cmd_input) elif "commd_list" in cmd_input: commd_list(cmd_input) else: invalidCommand(cmd_input) login() maincmd()
Código
Saludos
#!/usr/bin/python3 # -*- coding: utf-8 -*- import calendar from datetime import datetime, date, time, timedelta import time def date_cmd(args): date_now = datetime.now() time_epoch = time.time() try: cmd_input = args.split(' ') argument = cmd_input[1] if argument == "-e": print("Epoch time: %s" % time_epoch) elif argument == "-12": date_format_12 = "%d/%m/%Y %I:%m %p" date_12 = date_now.strftime(date_format_12) print("Date (12 hours format): %s" % date_12) elif argument == "-24": date_format_24 = "%d/%m/%Y %H:%M:%S" date_24 = date_now.strftime(date_format_24) print("Date (24 hours format): %s" % date_24) elif argument == "-h": print(help_arg) else: print("\033[1;36m"+'invalid argument for "date" command') help_arg() except IndexError: help_arg() except TypeError: help_arg() finally: print("\033[;37m") def help_arg(): print("""Date command made by n1sendev. ╔════════════════════════╗ ║ \"date\" command help: ║ ╠════════════════════════╩═════════════════════════════╗ ║Arguments (options): ║ ║ ║ ║-12 = Display the date and the hour in 12-hour format.║ ║-24 = Display the date and the hour in 24-hour format.║ ║-e = Display the date and time in epoch format. ║ ║-h = Display this help menu. ║ ╚══════════════════════════════════════════════════════╝ """)
PD: Esas palabras raras que empiezan con & alparecer es un bug del foro, ya que enrealidad son carcacteres para dibujar cajas, estan en ASCII