Browse Source

Added logging feature

Everything is explained in limf -h.
pull/23/head
Mikołaj 'lich' Halber 4 years ago
parent
commit
47d133c2fb
3 changed files with 17 additions and 4 deletions
  1. 6
    0
      limf/cli.py
  2. 10
    3
      limf/parse_arguments.py
  3. 1
    1
      setup.py

+ 6
- 0
limf/cli.py View File

@@ -35,6 +35,12 @@ def main():
parser.add_argument('-nc', dest='no_cloudflare', action='store_const',
const=True, default=False,
help='Do not use hosts which use Cloudflare.')
parser.add_argument('--log-file', metavar="LOGFILE", dest="logfile",
default="~/limf.log",
help="The location of log file")
parser.add_argument('--log', dest='log', action="store_const",
const=True, default=False,
help="Enables the logging feature, default logfile is ~/limf.log")
args = parser.parse_args()
try:
if args.local_list:

+ 10
- 3
limf/parse_arguments.py View File

@@ -21,6 +21,7 @@ def parse_arguments(args, clone_list):
"""
Makes parsing arguments a function.
"""
returned_string=""
host_number = args.host
if args.show_list:
print(generate_host_string(clone_list, "Available hosts: "))
@@ -54,10 +55,11 @@ def parse_arguments(args, clone_list):
while True:
try:
if args.encrypt:
print(encrypt_files(clone_list[host_number], args.only_link, i))
returned_string = encrypt_files(clone_list[host_number], args.only_link, i)
else:
print(upload_files(open(i, 'rb'), \
clone_list[host_number], args.only_link, i))
returned_string = upload_files(open(i, 'rb'), \
clone_list[host_number], args.only_link, i)
print(returned_string)
except IndexError:
#print('Selected server (' + clone_list[host_number][0] + ') is offline.')
#print('Trying other host.')
@@ -66,6 +68,11 @@ def parse_arguments(args, clone_list):
except IsADirectoryError:
print('limf does not support directory upload, if you want to upload ' \
'every file in directory use limf {}/*.'.format(i.replace('/', '')))
if args.log:
with open(os.path.expanduser(args.logfile), "a+") as logfile:
logfile.write(returned_string)
logfile.write("\n")
break
else:
print("limf: try 'limf -h' for more information")

+ 1
- 1
setup.py View File

@@ -9,7 +9,7 @@ from setuptools import setup

setup(
name='limf',
version='0.5.5',
version='0.6.0',
url='http://github.com/lich/limf',
license='MIT',
author='Mikolaj \'lich\' Halber',

Loading…
Cancel
Save