示例#1
0
def order(client, market, type, vol, btc):
    o_id = None
    try:
        o = client.createOrder(market, type, vol, btc, 'limit')
        o_id = o['id']
        os = client.getOrder(o_id)
        timeout.set_timeout(10)
        while os['state'] == 'pending' or os['state'] == 'received':
            os = client.getOrder(o_id)
        timeout.stop_timeout()
        if os['state'] == 'canceled':
            print >> sys.stderr, "Buda Order Canceled by user?... order_id:", o_id, "market:", market, "type:", type, "vol:", vol, "btc:", btc
            sys.stderr.flush()
            raise EnvironmentError("Orden" + str(o_id) +
                                   "cancelado por el usuario?")
    except timeout.TimeoutError as e:
        print >> sys.stderr, "Buda Timeout... market:", market, "type:", type, "vol:", vol, "btc:", btc, str(
            e)
        sys.stderr.flush()
        raise e
    except ConnectionError as e:
        print >> sys.stderr, "Buda Connection error... market:", market, "type:", type, "vol:", vol, "btc:", btc, str(
            e)
        sys.stderr.flush()
        raise e
    finally:
        if o_id is not None and 'os' in locals() and 'state' in os and (
                os['state'] not in ['traded']):
            client.cancelOrder(o_id)

    return os if 'os' in locals() else None
示例#2
0
 def handle_thread(self, thread, progress):
     if thread.is_alive() and not thread.error:
         set_timeout(lambda: self.handle_thread(thread, progress), 100)
     else:
         progress.stop()
         if thread.result:
             plugin_response = json.loads(thread.result.decode('utf-8'))
             self.plugins = PluginList(plugin_response)
             self.show_quick_panel(self.plugins.quick_panel_list(), self.open_in_browser, font=0)
         else:
             self.error_message(self.error_text_for(thread))
示例#3
0
文件: gulp.py 项目: wufeishow/sublime
 def handle_thread(self, thread, progress):
     if thread.is_alive() and not thread.error:
         set_timeout(lambda: self.handle_thread(thread, progress), 100)
     else:
         progress.stop()
         if thread.result:
             plugin_response = json.loads(thread.result.decode('utf-8'))
             self.plugins = PluginList(plugin_response)
             self.show_quick_panel(self.plugins.quick_panel_list(),
                                   self.open_in_browser,
                                   font=0)
         else:
             self.error_message(self.error_text_for(thread))
def insert_in_output_view(view, content, in_new_tab):
    if view is None:
        return

    if in_new_tab and view.is_loading():
        set_timeout(lambda: insert_in_output_view(view, content, in_new_tab), 10)
    else:
        decoded_contenet = content if is_sublime_text_3 else CrossPlatformCodecs.force_decode(content)

        view.set_read_only(False)
        view.run_command("view_insert", { "size": view.size(), "content": decoded_contenet })
        view.set_viewport_position((0, view.size()), True)
        view.set_read_only(True)
示例#5
0
def insert_in_output_view(view, content, in_new_tab):
    if view is None:
        return

    if in_new_tab and view.is_loading():
        set_timeout(lambda: insert_in_output_view(view, content, in_new_tab),
                    10)
    else:
        decoded_contenet = content if is_sublime_text_3 else CrossPlatformCodecs.force_decode(
            content)

        view.set_read_only(False)
        view.run_command("view_insert", {
            "size": view.size(),
            "content": decoded_contenet
        })
        view.set_viewport_position((0, view.size()), True)
        view.set_read_only(True)
示例#6
0
 def set_output_close_on_timeout(self):
     timeout = self.settings.get(
         "results_autoclose_timeout_in_milliseconds", False)
     if timeout:
         set_timeout(self.close_panel, timeout)
示例#7
0
 def set_output_close_on_timeout(self):
     timeout = self.settings.get("results_autoclose_timeout_in_milliseconds", False)
     if timeout:
         set_timeout(self.close_panel, timeout)