summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xsrc/leap/bitmask/cli/bitmask_cli.py6
-rw-r--r--src/leap/bitmask/cli/logs.py64
2 files changed, 70 insertions, 0 deletions
diff --git a/src/leap/bitmask/cli/bitmask_cli.py b/src/leap/bitmask/cli/bitmask_cli.py
index 091b73f..64fe74b 100755
--- a/src/leap/bitmask/cli/bitmask_cli.py
+++ b/src/leap/bitmask/cli/bitmask_cli.py
@@ -30,6 +30,7 @@ from leap.bitmask.cli.mail import Mail
from leap.bitmask.cli.webui import WebUI
from leap.bitmask.cli import command
from leap.bitmask.cli.user import User
+from leap.bitmask.cli.logs import Logs
class BitmaskCLI(command.Command):
@@ -44,6 +45,7 @@ SERVICE COMMANDS:
eip Encrypted Internet Proxy
keys Bitmask Keymanager
ui Bitmask User Interface
+ logs Manages bitmask daemon logs
GENERAL COMMANDS:
@@ -79,6 +81,10 @@ GENERAL COMMANDS:
webui = WebUI()
return webui.execute(raw_args)
+ def logs(self, raw_args):
+ logs = Logs()
+ return logs.execute(raw_args)
+
# Single commands
def start(self, raw_args):
diff --git a/src/leap/bitmask/cli/logs.py b/src/leap/bitmask/cli/logs.py
new file mode 100644
index 0000000..11903ee
--- /dev/null
+++ b/src/leap/bitmask/cli/logs.py
@@ -0,0 +1,64 @@
+# -*- coding: utf-8 -*-
+# keys
+# Copyright (C) 2016 LEAP
+#
+# 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 3 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, see <http://www.gnu.org/licenses/>.
+"""
+Bitmask Command Line interface: logs
+"""
+import argparse
+import commands
+import os.path
+import sys
+
+from colorama import Fore
+
+from twisted.internet import defer
+from twisted.python.procutils import which
+
+from leap.bitmask.cli import command
+from leap.common.config import get_path_prefix
+
+
+
+class Logs(command.Command):
+ usage = '''{name} logs <subcommand>
+
+Bitmask Log Handling
+
+SUBCOMMANDS:
+
+ send Send last bitmaskd log
+'''.format(name=command.appname)
+
+ def send(self, raw_args):
+ _bin = which('pastebinit')
+ if not _bin:
+ error('pastebinit not found. install it to upload logs.')
+ return defer.succeed(None)
+ log_path = os.path.abspath(
+ os.path.join(get_path_prefix(), 'leap', 'bitmaskd.log'))
+ output = commands.getoutput('{0} -b {1} {2}'.format(
+ _bin[0], 'paste.debian.net', log_path))
+ uri = output.replace('debian.net/', 'debian.net/plain/')
+ success(uri)
+ return defer.succeed(None)
+
+
+def error(msg):
+ print Fore.RED + msg + Fore.RESET
+
+
+def success(msg):
+ print Fore.GREEN + '[+] Bitmaskd logs pasted to ' + msg + Fore.RESET