如何从Python控制马戏团中的手表/流程

时间:2017-02-02 17:36:42

标签: python circusd

我使用ini[circus] endpoint = tcp://127.0.0.1:5555 pubsub_endpoint = tcp://127.0.0.1:5556 check_delay = 5 logoutput = /var/log/circus.log [watcher:test-worker] working_dir = /home/ubuntu/app cmd = python args = test.py numprocesses = 1 文件运行了很少的自定义Python进程:

circusctl

我可以使用circusctl 0.14.0 (circusctl) list test-worker (circusctl)

来控制这些观察者
list

但我想使用我的Python脚本控制这些(startstoprestartcircus等。

我已经检查了文档https://github.com/hasyapanchasara/PushKit_SilentPushNotification,但它的示例似乎在不同的circusd上下文/实例中运行进程,并且它没有连接到正在运行的# coding=utf-8 from kivy.app import App from random import random, randint,choice from kivy.uix.widget import Widget from kivy.uix.button import Button from kivy.graphics import Color, Rectangle from kivy.uix.floatlayout import FloatLayout from kivy.uix.behaviors import ButtonBehavior from kivy.uix.screenmanager import ScreenManager, Screen, FadeTransition import datetime from kivy.uix.label import Label from kivy.uix.popup import Popup from kivy.uix.image import Image class MyButton(ButtonBehavior, Image): def __init__(self, **kwargs): super(MyButton, self).__init__(**kwargs) self.source = 'butto.png' self.size_hint = (0.3, 0.3) def on_press(self): self.source = 'pressed.png' def on_release(self,*args): self.source = 'butto.png' class exitt(ButtonBehavior, Image): def __init__(self, **kwargs): super(exitt, self).__init__(**kwargs) self.source = 'exit.png' def on_press(self): self.source = 'bluext.png' def on_release(self,*args): self.source = 'exit.png' class killbtn(ButtonBehavior, Image): def __init__(self, **kwargs): super(killbtn, self).__init__(**kwargs) self.source = 'killbtn.zip' def on_release(self,*args): self.source = 'killbtn.zip' class ScreenOne(Screen): def __init__ (self,**kwargs): super (ScreenOne, self).__init__(**kwargs) my_box1 = FloatLayout() bubine = ['a','b'] frasi=['a','b'] bubilist= choice(bubine) buongglist=choice(frasi) my_label1 = Label(text="[color=ff3333]%s, %s![/color]" %(buongglist,bubilist),size_hint_y= .9, text_size=(330, None),halign= 'center', height=self.size[1],line_wrap=True, font_size='24dp', markup= True,pos_hint= {'center_x':.5, 'center_y':.77}) my_button1=MyButton() my_button1.size_hint=(.6, .35) my_button1.pos_hint= {'center_x':.5, 'center_y':.3} my_button1.bind(on_release=self.changer) my_box1.add_widget(my_label1) my_box1.add_widget(my_button1) self.add_widget(my_box1) with self.canvas.before: Color(.5, .5, .9, 1) self.rect = Rectangle(pos=self.pos, size=self.size) self.bind(size=self.update_rect) def update_rect(self, instance, value): self.rect.pos = self.pos self.rect.size = self.size def my_callback(self,dt): App.get_running_app().stop() def changer(self,*args): legg=open('gg.txt', 'r') ultimogg=legg.readline() legg.close() oggi=datetime.datetime.now().strftime('%d') if ultimogg==oggi: kill= killbtn() kill.bind(on_press=self.uccidi) popup = Popup(title='Kill.',content=kill,size_hint=(.75,.75)) popup.bind(on_dismiss=self.my_callback) popup.open() else: self.manager.current = 'screen3' def uccidi(self,*args): zipcaso=randint(1001,1013) load_zipped_png_files = Image(source = 'GIFS/%s.zip'% zipcaso,anim_loop=1,anim_delay = 0.1,keep_ratio = False,keep_data = True,size_hint=(1,1)) popup = Popup(title='Cosi impara.',content=load_zipped_png_files,size_hint=(.75,.75)) popup.bind(on_dismiss=self.my_callback) popup.open() class ScreenThree(Screen): def __init__(self,**kwargs): super (ScreenThree,self).__init__(**kwargs) my_box1 = FloatLayout() oggi=datetime.datetime.now().strftime('%d') if oggi=='23'or oggi=='14'or oggi=='26' or oggi=='01': mese=datetime.datetime.now().strftime('%m') if oggi=='23' and mese=='07': numoggi = 'luglio' elif oggi=='14'and mese=='02': popup = Popup(title='Buon anniversario stella!',content=Label(text='Hello world'),size_hint=(.75,.75)) popup.open() numoggi = 'febbraio' elif oggi=='26' and mese=='08': numoggi = 'agosto' elif oggi=='01' and mese=='01': numoggi = 'gennaio' else: legg=open('numimg.txt', 'r') ultimogg=legg.readline() legg.close() if ultimogg=='1004': numoggi=1001 else: numoggi=int(ultimogg)+1 file = open('numimg.txt','w') file.seek(0) file.write(str(numoggi)) file.close() file = open('gg.txt','w') file.seek(0) file.write(oggi) file.close() if numoggi>1019: miraglio = Image(source = 'IMMAGO/%s.zip'% numoggi,keep_ratio = False,keep_data = True,size_hint=(1,1)) else: miraglio = Image(source = 'IMMAGO/%s.jpg'% numoggi,keep_ratio = False,keep_data = True,size_hint=(1,1)) my_button1 = exitt() my_button1.size_hint = (0.075, 0.075) my_button1.pos_hint= {'right': .97,'top':.97} my_button1.bind(on_release=self.changer) my_box1.add_widget(miraglio) my_box1.add_widget(my_button1) self.add_widget(my_box1) def changer(self,*args): App.get_running_app().stop() class TestApp(App): def build(self): self.icon = 'icona.png' my_screenmanager = ScreenManager() my_screenmanager= ScreenManager(transition=FadeTransition()) screen1 = ScreenOne(name='screen1') screen3 = ScreenThree(name='screen3') my_screenmanager.add_widget(screen1) my_screenmanager.add_widget(screen3) return my_screenmanager if __name__ == '__main__': TestApp().run() 实例。< / p>

0 个答案:

没有答案