From f21a44dd48a1ea7401378830fc38e5a864e927e5 Mon Sep 17 00:00:00 2001 From: Marcelo Glezer Date: Thu, 15 Jan 2015 08:46:10 -0300 Subject: [PATCH] removed pyperclip hard dependencies --- .travis.yml | 4 +--- libmproxy/console/flowlist.py | 28 +++++++++++++++++----------- libmproxy/console/flowview.py | 28 +++++++++++++++++----------- 3 files changed, 35 insertions(+), 25 deletions(-) diff --git a/.travis.yml b/.travis.yml index a4215e686..2dc898c21 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,10 +1,8 @@ language: python -sudo: true +sudo: false python: - "2.7" - pypy -before_install: - - "sudo apt-get install -y xclip" # command to install dependencies, e.g. pip install -r requirements.txt --use-mirrors install: - "pip install --upgrade --src . -r requirements.txt" diff --git a/libmproxy/console/flowlist.py b/libmproxy/console/flowlist.py index 44b328556..f97a7a114 100644 --- a/libmproxy/console/flowlist.py +++ b/libmproxy/console/flowlist.py @@ -1,7 +1,10 @@ from __future__ import absolute_import import urwid -import pyperclip from . import common +try: + import pyperclip +except: + pyperclip = False def _mkhelp(): text = [] @@ -141,16 +144,19 @@ class ConnectionItem(common.WWrap): self.master.server_playback_path ) def server_copy_response(self, k): - if k == "c": - try: - pyperclip.copy(self.flow.response.get_decoded_content()) - except TypeError: - self.master.statusbar.message("Content is binary or can be converted to text") - elif k == "h": - try: - pyperclip.copy(str(self.flow.response.headers)) - except TypeError: - self.master.statusbar.message("Error converting headers to text") + if pyperclip: + if k == "c": + try: + pyperclip.copy(self.flow.response.get_decoded_content()) + except TypeError: + self.master.statusbar.message("Content is binary or can be converted to text") + elif k == "h": + try: + pyperclip.copy(str(self.flow.response.headers)) + except TypeError: + self.master.statusbar.message("Error converting headers to text") + else: + self.master.statusbar.message("No clipboard support on your system, sorry.") def keypress(self, (maxcol,), key): key = common.shortcuts(key) diff --git a/libmproxy/console/flowview.py b/libmproxy/console/flowview.py index 08a0148f5..667a74074 100644 --- a/libmproxy/console/flowview.py +++ b/libmproxy/console/flowview.py @@ -4,7 +4,10 @@ import urwid from . import common, grideditor, contentview from .. import utils, flow, controller from ..protocol.http import HTTPResponse, CONTENT_MISSING, decoded -import pyperclip +try: + import pyperclip +except: + pyperclip = False class SearchError(Exception): pass @@ -650,16 +653,19 @@ class FlowView(common.WWrap): self.master.refresh_flow(self.flow) def server_copy_response(self, k): - if k == "c": - try: - pyperclip.copy(self.flow.response.get_decoded_content()) - except TypeError: - self.master.statusbar.message("Content is binary or can be converted to text") - elif k == "h": - try: - pyperclip.copy(str(self.flow.response.headers)) - except TypeError: - self.master.statusbar.message("Error converting headers to text") + if pyperclip: + if k == "c": + try: + pyperclip.copy(self.flow.response.get_decoded_content()) + except TypeError: + self.master.statusbar.message("Content is binary or can be converted to text") + elif k == "h": + try: + pyperclip.copy(str(self.flow.response.headers)) + except TypeError: + self.master.statusbar.message("Error converting headers to text") + else: + self.master.statusbar.message("No clipboard support on your system, sorry.") def delete_body(self, t): if t == "m":