Skip to content
This repository has been archived by the owner on Jul 11, 2019. It is now read-only.

show duration on success #636

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def call(operation, use_mm_panel=True, **kwargs):
context=kwargs.get('context', None),
message=kwargs.get('message', None),
use_mm_panel=use_mm_panel,
start_time=time.time(),
process_id=util.get_random_string(10),
callback=kwargs.get('callback', None),
flags=kwargs.get('flags', None)
Expand All @@ -70,6 +71,7 @@ def __init__(self, operation, **kwargs):
self.view = None
self.window = None
self.printer = None
self.start_time = kwargs.get('start_time', time.time())
self.process_id = time.strftime("%a, %d %b %Y %H:%M:%S", time.localtime())
self.use_mm_panel = kwargs.get('use_mm_panel', False)
self.result = None #result of operation
Expand Down Expand Up @@ -192,11 +194,12 @@ def run(self):
ThreadTracker.remove(self)

#handles the result of the mm script
def handle_result(operation, process_id, printer, res, thread):
def handle_result(operation, process_id, start_time, printer, res, thread):
try:
context = {
"operation" : operation,
"process_id" : process_id,
"start_time" : start_time,
"printer" : printer,
"response" : res,
"thread" : thread
Expand Down
8 changes: 7 additions & 1 deletion lib/response_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import os
import sys
import html.parser
import time
import traceback
from .merge import MavensMateDiffThread
import MavensMate.util as util
Expand All @@ -17,11 +18,15 @@ class MavensMateResponseHandler(object):
def __init__(self, context):
self.operation = context.get('operation', None)
self.process_id = context.get('process_id', None)
self.start_time = context.get('start_time', None)
self.duration = 0
self.printer = context.get('printer', None)
self.thread = context.get('thread', None)
self.response = context.get('response', None)
self.process_region = self.printer.panel.find(self.process_id,0)
self.status_region = self.printer.panel.find(' Result: ',self.process_region.begin())
if self.start_time is not None:
self.duration = time.time() - self.start_time

try:
self.response = json.loads(self.response)
Expand Down Expand Up @@ -255,7 +260,8 @@ def __handle_compile_response(self, **kwargs):
success = self.response['result']['success']
if success:
util.clear_marked_line_numbers(self.thread.view)
self.__print_to_panel("Success")
msg = "Success, %.1fs" % self.duration
self.__print_to_panel(msg)
self.printer.hide()
return

Expand Down
2 changes: 1 addition & 1 deletion lib/threads.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def run(self, i):
if not self.thread.is_alive():
if hasattr(self.thread, 'result'):
#thread is done, we need to handle the result
self.thread.callback(self.thread.operation, self.thread.process_id, self.thread.printer, self.thread.result, self.thread)
self.thread.callback(self.thread.operation, self.thread.process_id, self.thread.start_time, self.thread.printer, self.thread.result, self.thread)
if self.thread.alt_callback != None:
self.thread.alt_callback(self.thread.context)
#self.thread.printer.panel.run_command('write_operation_status', {'text': self.thread.result, 'region': [self.thread.status_region.end(), self.thread.status_region.end()+10] })
Expand Down