How to use sleep method in Pytest

Best Python code snippet using pytest

Run Pytest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

doTask_Mianfei.js

Source: doTask_Mianfei.js Github

copy
1// 判断一个任务是否需要去做
2function isTodo_Mianfei(table) {
3    const ttl = table["title"];
4    const btt = table["buttonText"];
5    const n2 = btt.length;
6    if (btt === "去挑选" || btt === "去分享" || btt === "已完成") {
7        return false;
8    } else if (ttl.substr(0, 6) === "领肥料小提示" && btt.substr(n2 - 1, 1) === "见") {
9        return false;
10    } else if (ttl === "领肥料小提示(1/1)") {
11        return false;
12    } else if (ttl.substr(0, 8) === "领400肥料礼包" && btt.substr(n2 - 2, 2) === "可领") {
13        return false;
14    } else if (UnknowTasks_Mianfei.includes(ttl)) {
15        return false;
16    } else if (ttl.match("^去淘宝人生拿套装")) {
17        return HasFreeChouXinYuanLiHe;
18    } else if (ttl.substr(0, 9) === "逛逛支付宝芭芭农场" && !guangzhifubao_UI) {
19        return false;
20    } else {
21        return true;
22    }
23}
24
25
26// 做一个任务,并返回集肥料子页面(重载:按照第一次记录的坐标点击)
27function doTask_Mianfei(table, index) {
28    let buttonX = FirstPt_Tasks_Mianfei.x;
29    let buttonY = FirstPt_Tasks_Mianfei.y + Gap_Tasks_Mianfei * index;
30
31    const rollDist = 1 * Gap_Tasks_Mianfei;
32    const n = Math.floor(((index - (MAXN_Tasks_Mianfei - 1)) + 0) / 1);
33    const startx = FirstPt_Tasks_Mianfei.x;
34    const starty = FirstPt_Tasks_Mianfei.y + Gap_Tasks_Mianfei * 3;
35    if (index > (MAXN_Tasks_Mianfei - 1)) {
36        //第7个开始要滚动
37        for (let i = 0; i < n; i++) {
38            swipeToPoint(startx, starty, startx, starty - rollDist, 200 * 1);
39            sleep(500);
40        }
41        buttonY = FirstPt_Tasks_Mianfei.y + Gap_Tasks_Mianfei * (MAXN_Tasks_Mianfei - 1);
42    }
43
44    //根据具体任务去做
45    const ttl = table["title"];
46    const btt = table["buttonText"];
47    if ((ttl.substr(0, 5) === "逛精选好物" && btt === "去逛逛") || (ttl.substr(0, 5) === "逛精选商品" && btt === "去逛逛")) {
48        //时钟,快,15s
49        clickPoint(buttonX, buttonY);
50        sleep(17000);
51        while (true) {
52            if (has(text('浏览完成,现在下单立即得1万肥料!'))) {
53                while (true) {
54                    if (has(text("浏览精选好货").clz("android.view.View"))) {
55                        let node = text("浏览精选好货").clz("android.view.View").getOneNodeInfo(3000);
56                        let sbls = node.parent().allChildren();
57                        sbls[0].child(0).clickCenter();
58                        sleep(3000);
59                    } else {
60                        break;
61                    }
62                }
63                break;
64            }
65            sleep(1000);
66        }
67    } else if (((ttl.indexOf("短视频") > -1) && btt === "去浏览")) {
68        //进度条,加载最慢,30s
69        clickPoint(buttonX, buttonY);
70        sleep(35000);
71        while (true) {
72            if (has(text('任务已经全部完成啦').clz('android.view.View'))) {
73                click(id("com.taobao.taobao:id/tbvideo_back").clz("android.widget.ImageView"));
74                sleep(4000);
75                break;
76            } else if (!has(text("滑动浏览得肥料").clz("android.view.View"))) {
77                //卡了,没进度条
78                while (true) {
79                    if (has(id("com.taobao.taobao:id/tbvideo_back").clz("android.widget.ImageView"))) {
80                        click(id("com.taobao.taobao:id/tbvideo_back").clz("android.widget.ImageView"));
81                    } else {
82                        break;
83                    }
84                    sleep(4000);
85                }
86                break;
87            }
88            sleep(2000);
89        }
90    } else if (((ttl.indexOf("直播") > -1) && btt === "去浏览") || (ttl.match("^观看.+") && btt === "去浏览")) {
91        //进度条,加载慢,15s
92        clickPoint(buttonX, buttonY);
93        sleep(25000);
94        while (true) {
95            if (has(text('任务已经全部完成啦').clz('android.view.View'))) {
96                while (true) {
97                    if (has(id("com.taobao.taobao:id/taolive_close_new_layout").clz("android.widget.LinearLayout"))) {
98                        let node = id("com.taobao.taobao:id/taolive_close_new_layout").clz("android.widget.LinearLayout").getOneNodeInfo(3000);
99                        node.child(2).clickCenter();
100                    } else {
101                        break;
102                    }
103                    sleep(4000);
104                }
105                break;
106            } else if (!has(text("滑动浏览得肥料").clz("android.view.View"))) {
107                //卡了,没进度条
108                while (true) {
109                    if (has(id("com.taobao.taobao:id/taolive_close_new_layout").clz("android.widget.LinearLayout"))) {
110                        let node = id("com.taobao.taobao:id/taolive_close_new_layout").clz("android.widget.LinearLayout").getOneNodeInfo(3000);
111                        node.child(2).clickCenter();
112                    } else {
113                        break;
114                    }
115                    sleep(4000);
116                }
117                break;
118            }
119            sleep(2000);
120        }
121    } else if ((ttl.match("^浏览.+店") && btt === "去浏览") || (ttl.substr(0, 3) === "逛一逛" && btt === "去浏览") || (ttl.substr(0, 7) === "逛网红新潮品牌" && btt === "去浏览") || (ttl.match("^逛.+会场") && btt === "去浏览") || (ttl.match("^浏览会员.+") && btt === "去浏览")) {
122        //进度条,加载一般,15s
123        clickPoint(buttonX, buttonY);
124        sleep(20000);
125        while (true) {
126            if (has(text('任务已经全部完成啦').clz('android.view.View'))) {
127                while (true) {
128                    if (has(text("返回").clz("android.widget.Button"))) {
129                        click(text("返回").clz("android.widget.Button"));
130                    } else {
131                        break;
132                    }
133                    sleep(3000);
134                }
135                break;
136            } else if (!has(text("滑动浏览得肥料").clz("android.view.View"))) {
137                //卡了,没进度条
138                while (true) {
139                    if (has(text("返回").clz("android.widget.Button"))) {
140                        click(text("返回").clz("android.widget.Button"));
141                    } else {
142                        break;
143                    }
144                    sleep(3000);
145                }
146                break;
147            }
148            sleep(2000);
149        }
150    } else if (((ttl.substr(0, 8) === "逛领券中心抢神券") && btt === "去浏览")) {
151        //进度条,加载一般,15s
152        clickPoint(buttonX, buttonY);
153        sleep(20000);
154        while (true) {
155            if (has(text('任务已经全部完成啦').clz('android.view.View'))) {
156                while (true) {
157                    if (has(desc("返回").clz("android.widget.FrameLayout"))) {
158                        click(desc("返回").clz("android.widget.FrameLayout"));
159                    } else {
160                        break;
161                    }
162                    sleep(3000);
163                }
164                break;
165            } else if (!has(text("滑动浏览得肥料").clz("android.view.View"))) {
166                //卡了,没进度条
167                while (true) {
168                    if (has(desc("返回").clz("android.widget.FrameLayout"))) {
169                        click(desc("返回").clz("android.widget.FrameLayout"));
170                    } else {
171                        break;
172                    }
173                    sleep(3000);
174                }
175                break;
176            }
177            sleep(2000);
178        }
179    } else if ((ttl.substr(0, 9) === "浏览获限时办理礼包" && btt === "去浏览")) {
180        //进度条,加载一般,15s
181        clickPoint(buttonX, buttonY);
182        sleep(20000);
183        while (true) {
184            if (has(text('任务已经全部完成啦').clz('android.view.View'))) {
185                while (true) {
186                    if (has(desc("转到上一层级").clz("android.widget.ImageButton"))) {
187                        click(desc("转到上一层级").clz("android.widget.ImageButton"));
188                    } else {
189                        break;
190                    }
191                    sleep(3000);
192                }
193                break;
194            } else if (!has(text("滑动浏览得肥料").clz("android.view.View"))) {
195                //卡了,没进度条
196                while (true) {
197                    if (has(desc("转到上一层级").clz("android.widget.ImageButton"))) {
198                        click(desc("转到上一层级").clz("android.widget.ImageButton"));
199                    } else {
200                        break;
201                    }
202                    sleep(3000);
203                }
204                break;
205            }
206            sleep(2000);
207        }
208    } else if (ttl.substr(0, 7) === "浏览超惠买爆款" && btt === "去浏览") {
209        //进度条,加载较快,15s
210        clickPoint(buttonX, buttonY);
211        sleep(17000);
212        while (true) {
213            if (has(text('任务已经全部完成啦').clz('android.view.View'))) {
214                while (true) {
215                    if (has(text("正品低价 好货闭眼买").clz("android.view.View"))) {
216                        let node = text("正品低价 好货闭眼买").clz("android.view.View").getOneNodeInfo(3000);
217                        let sbls = node.parent().previousSiblings();
218                        sbls[0].clickCenter();
219                    } else {
220                        break;
221                    }
222                    sleep(3000);
223                }
224                break;
225            } else if (!has(text("滑动浏览得肥料").clz("android.view.View"))) {
226                //卡了,没进度条
227                while (true) {
228                    if (has(text("正品低价 好货闭眼买").clz("android.view.View"))) {
229                        let node = text("正品低价 好货闭眼买").clz("android.view.View").getOneNodeInfo(3000);
230                        let sbls = node.parent().previousSiblings();
231                        sbls[0].clickCenter();
232                    } else {
233                        break;
234                    }
235                    sleep(3000);
236                }
237                break;
238            }
239            sleep(2000);
240        }
241    } else if ((ttl.substr(0, 8) === "领400肥料礼包" && btt === "去领取") || (ttl.substr(0, 6) === "领肥料小提示" && btt === "知道了")) {
242        //领取
243        clickPoint(buttonX, buttonY);
244        sleep(3000);
245    } else if (ttl.substr(0, 9) === "浏览金币小镇得肥料" && btt === "去浏览") {
246        //进度条,加载一般,15s
247        clickPoint(buttonX, buttonY);
248        sleep(20000);
249        while (true) {
250            if (has(text('任务已经全部完成啦').clz('android.view.View'))) {
251                while (true) {
252                    if (has(text("返回").clz("android.widget.Button"))) {
253                        click(text("返回").clz("android.widget.Button"));
254                    } else {
255                        break;
256                    }
257                    sleep(3000);
258                }
259                break;
260            } else if (!has(text("滑动浏览得肥料").clz("android.view.View"))) {
261                //卡了,没进度条
262                while (true) {
263                    if (has(text("返回").clz("android.widget.Button"))) {
264                        click(text("返回").clz("android.widget.Button"));
265                    } else {
266                        break;
267                    }
268                    sleep(3000);
269                }
270                break;
271            }
272            sleep(2000);
273        }
274    } else if (ttl.substr(0, 8) === "去淘宝人生拿套装" && btt === "去逛逛") {
275        //抽心愿礼盒得300肥料
276        clickPoint(buttonX, buttonY);
277        sleep(5000);
278        while (true) {
279            if (isInTaobaorenshengMain()) {
280                sleep(2000);
281                break;
282            }
283            sleep(2000);
284        }
285        let pcxylh = findFreeChouXinYuanLiHe();
286        if (pcxylh) {
287            clickPoint(pcxylh.x, pcxylh.y);
288            sleep(4000);
289            back();
290            sleep(5000);
291        } else {
292            //x6抽一次,不做了,退出
293            back();
294            sleep(5000);
295        }
296        while (true) {
297            if (has(text('淘宝人生').clz('android.webkit.WebView'))) {
298                let zjtc = findExitInTBRS();
299                if (zjtc) {
300                    clickPoint(zjtc.x, zjtc.y);
301                    sleep(3000);
302                    break;
303                }
304            }
305            sleep(2000);
306        }
307        HasFreeChouXinYuanLiHe = false;
308    } else if (ttl.substr(0, 9) === "逛逛支付宝芭芭农场") {
309        clickPoint(buttonX, buttonY);
310        sleep(10000);
311        IsStartZhifubaoExcp = true;
312        sleep(5000);
313        doZhifubaoBaBaNongChang();
314        logd("支付宝任务全部完成~");
315        //返回淘宝
316        logd("准备返回淘宝...");
317        back();
318        sleep(8000);
319        while (true) {
320            if (getRunningPkg() === "com.eg.android.AlipayGphone") {
321                back();
322            } else if (getRunningPkg() === "com.taobao.taobao") {
323                sleep(2000);
324                returnJifeiliao_Mianfei();
325                sleep(1000);
326                break;
327            } else {
328                openMyTaobao();
329                sleep(6000);
330                gotoMianfeilingshuiguoSinceClickBaba();
331                sleep(2000);
332                logd("支付宝返回淘宝:退了支付宝,重开淘宝,进入免费领水果主页面");
333                clickPoint(xy_Jifeiliao_Mianfei.x, xy_Jifeiliao_Mianfei.y);
334                sleep(2000);
335                break;
336            }
337            sleep(4000);
338        }
339    } else if ((ttl.match("^浏览.+") && btt === "去浏览")) {
340        //最后判断是不是浏览**
341        //进度条,加载一般,15s
342        clickPoint(buttonX, buttonY);
343        sleep(20000);
344        while (true) {
345            if (has(text('任务已经全部完成啦').clz('android.view.View'))) {
346                while (true) {
347                    if (has(text("返回").clz("android.widget.Button"))) {
348                        click(text("返回").clz("android.widget.Button"));
349                    } else {
350                        break;
351                    }
352                    sleep(3000);
353                }
354                break;
355            } else if (!has(text("滑动浏览得肥料").clz("android.view.View"))) {
356                //卡了,没进度条
357                while (true) {
358                    if (has(text("返回").clz("android.widget.Button"))) {
359                        click(text("返回").clz("android.widget.Button"));
360                    } else {
361                        break;
362                    }
363                    sleep(3000);
364                }
365                break;
366            }
367            sleep(2000);
368        }
369    } else {
370        logd("淘宝未知任务!", ttl);
371        UnknowTasks_Mianfei.push(ttl);
372    }
373
374    //判断返回的页面,并回到集肥料
375    returnJifeiliao_Mianfei();
376
377    if (index > (MAXN_Tasks_Mianfei - 1)) {
378        //第7个开始要滚回去
379        for (let i = 0; i < n; i++) {
380            swipeToPoint(startx, starty, startx, starty + 2 * rollDist, 200);
381            sleep(500);
382        }
383    }
384}
Full Screen

MainContainer.js

Source: MainContainer.js Github

copy
1import React from 'react'
2import SleepForm from './SleepForm'
3import SleepEntry from './SleepEntry'
4import Graph from './Graph'
5
6 const MainContainer = (props) => {
7    // console.log("MainContainer", props.sleepData)
8
9
10    const sleep = props.sleepData
11    
12    sleep.sort((a,b)=>{
13        
14        const bdate = b.date.split('-')
15        const adate = a.date.split('-')
16        console.log(adate)
17        return bdate[0] - adate[0] || bdate[1] - adate[1] || bdate[2] - adate[2];
18    })
19
20    // console.log("MainContainer state", sleep)
21    // console.log("user stuff", props.userData)
22    const sleepEntries = sleep.map((sleep) => (
23        // console.log("mapped", sleep)
24       <SleepEntry  key={sleep.sleepid} sleep={sleep} entryDate={sleep.date} />
25        
26  ))
27   
28    return (
29        <div className="containerG">
30         
31            <SleepForm userData={props.userData} />
32            <div className="graphContainer">
33            <Graph sleepData={props.sleepData}/>
34            </div>
35            <div className="entries">
36            {sleepEntries}
37            </div>
38            {/* <SleepEntry key={sleep.sleepid} sleep={sleep} entryDate={sleep.date} /> */}
39            {/* <SleepEntry key={sleep.sleepid} sleep={sleep} entryDate={sleep.date} /> */}
40
41        </div>
42    )
43}
44export default MainContainer
Full Screen

SleepAddScreen.js

Source: SleepAddScreen.js Github

copy
1import React, { Component } from "react";
2import {
3  StyleSheet,
4  Text,
5  View,
6  TouchableOpacity,
7  Dimensions,
8  Switch,
9  ScrollView,
10  Image
11} from "react-native";
12import textStyles from "./../../common/TextStyles";
13import ThemeStyle from "../../styles/ThemeStyle";
14import Header from "./../../components/Header";
15import { Transition } from "react-navigation-fluid-transitions";
16import LinearGradient from "react-native-linear-gradient";
17import CustomButton from "./../../components/Button";
18import { withStore } from "../../utils/StoreUtils";
19import { setSleepData } from "../../actions/RecordActions";
20import { asyncStorageConstants, getScreens } from "../../constants";
21import { recordScreenEvent, screenNames } from "../../utils/AnalyticsUtils";
22import DateTimePicker from "react-native-modal-datetime-picker";
23import moment from "moment";
24import Icon from "../../common/icons";
25import Card from "../../components/Card";
26import * as Animatable from "react-native-animatable";
27import { addSleepEntry, deleteSleepEntries, getSleepEntries } from "../../actions/NutritionixActions"
28import { showMessage } from "react-native-flash-message";
29import { setTopSafeAreaView } from "../../actions/AppActions";
30
31const { width, height } = Dimensions.get("window");
32
33class SleepAddScreen extends Component {
34  constructor(props) {
35    super(props);
36    this.defaultSleepTime = moment();
37    this.defaultSleepTime.hours(
38      props.isEdit && props.editEntry.bedTime
39        ? moment(props.editEntry.bedTime).get("hours")
40        : 22
41    );
42    this.defaultSleepTime.minutes(
43      props.isEdit && props.editEntry.bedTime
44        ? moment(props.editEntry.bedTime).get("minutes")
45        : 15
46    );
47    this.defaultWakeTime = moment();
48    this.defaultWakeTime.hours(
49      props.isEdit && props.editEntry.wakeTime
50        ? moment(props.editEntry.wakeTime).get("hours")
51        : 6
52    );
53    this.defaultWakeTime.minutes(
54      props.isEdit && props.editEntry.wakeTime
55        ? moment(props.editEntry.wakeTime).get("minutes")
56        : 15
57    );
58    this.state = {
59      currentDate: props.isEdit ? moment(props.editEntry.dateTime) : moment(),
60      sleepTime: this.defaultSleepTime,
61      wakeTime: this.defaultWakeTime,
62      switch: props.isEdit ? props.editEntry.medication : false,
63      duration: this.calculateDuration(
64        this.defaultSleepTime,
65        this.defaultWakeTime
66      ),
67      duration_min: this.calculateDurationMin(
68        this.defaultSleepTime,
69        this.defaultWakeTime
70      )
71    };
72  }
73  
74  componentDidMount() {
75    this.props.setTopSafeAreaView(ThemeStyle.backgroundColor);
76    recordScreenEvent(screenNames.medication);
77  }
78
79  componentWillUnmount() {
80    this.props.setTopSafeAreaView(ThemeStyle.gradientStart);
81  }
82
83  calculateDuration(sleepTime, wakeTime) {
84    let hours = wakeTime.diff(sleepTime, "hours", true);
85    if (hours < 0) {
86      hours = 24 + hours;
87    }
88    const durationHours = Math.floor(hours);
89    const minutes = hours - durationHours;
90    let durationMins = Math.floor(minutes * 60);
91    if (durationMins < 10) {
92      durationMins = "0" + durationMins;
93    }
94    return durationHours + ":" + durationMins;
95  }
96
97  calculateDurationMin(sleepTime, wakeTime) {
98    let hours = wakeTime.diff(sleepTime, "hours", true);
99    if (hours < 0) {
100      hours = 24 + hours;
101    }
102    const durationHours = Math.floor(hours);
103    const minutes = hours - durationHours;
104    const durationMins = Math.floor(minutes * 60);
105    return durationHours * 60 + durationMins;
106  }
107
108  onClickAddSleep = () => {
109    var params = {
110      bed_time: this.state.sleepTime.toISOString(),
111      wake_time: this.state.wakeTime.toISOString(),
112      duration: this.state.duration,
113      duration_min: this.state.duration_min
114    }
115    let dateTime = this.state.currentDate.format("YYYY-MM-DD");
116    this.props.addSleepEntry(params, dateTime, onAdded => {
117      console.log("Success to upload sleep", onAdded)
118      showMessage({
119        message:'Sleep have been saved sucessfully.',
120        type: "success"
121      });
122      this.props.navigation.goBack(null);
123    })
124  }
125
126  render() {
127    return (
128      <View style={[ThemeStyle.pageContainer, { paddingHorizontal: 20 }]}>
129        <Header
130          title="Sleep"
131          goBack={() => {
132            this.props.navigation.goBack(null);
133          }}
134        />
135        <Animatable.View animation="fadeInUp">
136          <LinearGradient
137            style={{ marginTop: 12, borderRadius: 10 }}
138            start={{ x: 0.8, y: 0.2 }}
139            end={{ x: 0.2, y: 1 }}
140            colors={ThemeStyle.gradientColor}
141          >
142            <View style={{ flexDirection: "row" }}>
143              <TouchableOpacity
144                style={{ flex: 1, padding: 24, alignItems: "center" }}
145                onPress={() => {
146                  this.setState({
147                    isDatePickerVisible: true,
148                    dateType: "sleep"
149                  });
150                }}
151              >
152                <Image
153                  source={require("../../assets/images/redesign/Night-icon.png")}
154                  style={{ height: 72, marginVertical: 16 }}
155                  resizeMode="contain"
156                />
157                <Text
158                  style={[
159                    textStyles.GeneralTextBold,
160                    { textAlign: "center", color: "#333" }
161                  ]}
162                >
163                  Slept at
164                </Text>
165                <Text
166                  style={[
167                    textStyles.SubHeaderBold,
168                    { textAlign: "center", color: "#fff" }
169                  ]}
170                >
171                  {this.state.sleepTime.format("hh : mm A")}
172                </Text>
173              </TouchableOpacity>
174              <TouchableOpacity
175                style={{ flex: 1, padding: 24, alignItems: "center" }}
176                onPress={() => {
177                  this.setState({
178                    isDatePickerVisible: true,
179                    dateType: "wake"
180                  });
181                }}
182              >
183                <Image
184                  source={require("../../assets/images/redesign/Day-graphic.png")}
185                  style={{ height: 72, marginVertical: 16 }}
186                  resizeMode="contain"
187                />
188                <Text
189                  style={[
190                    textStyles.GeneralTextBold,
191                    { textAlign: "center", color: "#333" }
192                  ]}
193                >
194                  Wokeup at
195                </Text>
196                <Text
197                  style={[
198                    textStyles.SubHeaderBold,
199                    { textAlign: "center", color: "#fff" }
200                  ]}
201                >
202                  {this.state.wakeTime.format("hh : mm A")}
203                </Text>
204              </TouchableOpacity>
205            </View>
206          </LinearGradient>
207        </Animatable.View>
208        <Animatable.View
209          animation="fadeInUp"
210          style={{
211            borderRadius: 10,
212            ...ThemeStyle.shadow(),
213            backgroundColor: "#fff",
214            borderWidth: 2,
215            marginTop: 16,
216            borderColor: ThemeStyle.mainColor,
217            flexDirection: "row",
218            padding: 16,
219            alignItems: "center"
220          }}
221        >
222          <Image
223            source={require("../../assets/images/redesign/Sleep_Duration-graphic.png")}
224            style={{ height: 72 }}
225            resizeMode="contain"
226          />
227          <View style={{ flexDirection: "column", marginLeft: 24 }}>
228            <Text style={[textStyles.GeneralTextBold]}>{"Sleep Duration"}</Text>
229            <Text
230              style={[
231                textStyles.SubHeaderBold,
232                { color: ThemeStyle.mainColor }
233              ]}
234            >
235              {this.state.duration}
236            </Text>
237          </View>
238        </Animatable.View>
239        <DateTimePicker
240          isVisible={this.state.isDatePickerVisible}
241          date={
242            this.state.dateType === "sleep"
243              ? new Date(this.state.sleepTime.toISOString())
244              : new Date(this.state.wakeTime.toISOString())
245          }
246          mode="time"
247          onCancel={() => {
248            this.setState({
249              isDatePickerVisible: false
250            });
251          }}
252          onConfirm={date => {
253            console.log(date);
254            const selectedDate = moment(date);
255            if (this.state.dateType === "sleep") {
256              this.setState({
257                isDatePickerVisible: false,
258                sleepTime: selectedDate,
259                duration: this.calculateDuration(
260                  selectedDate,
261                  this.state.wakeTime
262                ),
263                duration_min: this.calculateDurationMin(
264                  selectedDate,
265                  this.state.wakeTime
266                )
267              });
268            }
269            if (this.state.dateType === "wake") {
270              this.setState({
271                isDatePickerVisible: false,
272                wakeTime: selectedDate,
273                duration: this.calculateDuration(
274                  this.state.sleepTime,
275                  selectedDate
276                ),
277                duration_min: this.calculateDurationMin(
278                  this.state.sleepTime, 
279                  selectedDate
280                )
281              });
282            }
283          }}
284        />
285        <CustomButton
286          style={{
287            position: "absolute",
288            bottom: 0,
289            marginBottom: 50,
290            alignSelf: "center"
291          }}
292          name={"Log Sleep"}
293          onPress={this.onClickAddSleep}
294        />
295      </View>
296    );
297  }
298}
299
300export default withStore(
301  SleepAddScreen,
302  state => ({
303    isEdit: state.record.isEdit,
304    editEntry: state.record.editEntry
305  }),
306  dispatch => ({
307    setTopSafeAreaView: color => dispatch(setTopSafeAreaView(color)),
308    setSleepData: data => dispatch(setSleepData(data)),
309    addSleepEntry: (query, date, data) =>
310      dispatch(addSleepEntry(query, date, data)),
311    deleteSleepEntries: (entryId, data) =>
312      dispatch(deleteSleepEntries(entryId, data)),
313    getSleepEntries: (date, fetchListData) =>
314      dispatch(getSleepEntries(date, fetchListData)),
315  })
316);
317
318var styles = StyleSheet.create({
319  inputBox: {
320    height: 300,
321    borderColor: "#fff",
322    borderWidth: 1,
323    paddingHorizontal: 24,
324    marginVertical: 24,
325    fontSize: 16,
326    textAlignVertical: "top",
327    color: "#000",
328    backgroundColor: "#fff"
329  },
330});
331
Full Screen

Monkeyrunner_TestCpp.py

Source: Monkeyrunner_TestCpp.py Github

copy
1# Imports the monkeyrunner modules used by this program
2import sys
3import subprocess
4import random
5import os
6from com.android.monkeyrunner import MonkeyRunner as mr
7from com.android.monkeyrunner import MonkeyDevice as md
8from com.android.monkeyrunner import MonkeyImage as  mi
9
10#Define test functions.
11def common_test(a,b,c):
12    for i in range(a,b):
13        mr.sleep(c)
14        device.touch(s_width/8*5,s_height/16*15,'DOWN_AND_UP')
15
16def random_click(a,b,c):
17    for i in range(a,b):
18        touch_x = random.randint(0,s_width/20*19)
19        touch_y = random.randint(0,s_height)
20        device.touch(touch_x,touch_y,'DOWN_AND_UP')
21        mr.sleep(c)
22
23def random_drag(a,b,c):
24    for i in range(a,b):
25        drag_x = random.randint(0,s_width/20*18)
26        drag_y = random.randint(0,s_height)
27        drop_x = random.randint(0,s_width/20*18)
28        drop_y = random.randint(0,s_height)
29        device.drag((drag_x,drag_y),(drop_x,drop_y))
30
31def check_activity(a):
32    print "get running activities..."
33    subprocess.call("adb shell ps > running_activities.txt",shell=True)
34    #subprocess.call("adb pull running_activities.txt",shell=True)
35    
36    f1 = open('running_activities.txt')
37    while True:
38        line = f1.readline()
39        if not line.find('org.cocos2dx.testcpp') == -1:
40            break;
41        if len(line) == 0:
42            str = "TestCpp wasn't running,maybe it has crashes,please checkout:"
43            f2 = file('monkeyrunner_Error.log','w')
44            print "get logcat information..."
45            f2.write(str)
46            f2.write(a)
47            #subprocess.call("adb shell logcat | $ANDROID_NDK/ndk-stack -sym $ANDROID_HOME/tools/obj/local/armeabi > monkeyrunner_Error.log",shell=True);
48            f2.close()
49            sys.exit(1)
50    print "subprocess has finished!"
51    f1.close()
52
53# Connects to the current device, returning a MonkeyDevice object
54device = mr.waitForConnection()
55if not device:
56    print >> sys.stderr,"fail"
57    check_activity("is there a device connect to the testing machine.")
58    sys.exit(1)
59else:
60    print "Start......"
61
62# Installs the Android package. Notice that this method returns a boolean, so you can test
63# to see if the installation worked.
64if device.installPackage(sys.argv[1]):
65    print "Install success!"
66else:
67    print "Install failed,please make sure you have put apk in the right places"
68    check_activity("you have put apk in the right place")
69    sys.exit(1)
70
71# sets a variable with the package's internal name
72package = 'org.cocos2dx.testcpp'
73print "Package name: "+ package
74
75# sets a variable with the name of an Activity in the package
76activity = 'org.cocos2dx.testcpp.TestCpp'
77print "Activity name: " + activity
78
79# sets the name of the component to start
80runComponent = package + '/' + activity
81
82# Runs the component
83device.startActivity(component=runComponent)
84print "Running activity......"
85
86#Set Screen's Length and Width
87s_width = 800
88s_height = 480
89
90#Set boolean variable of Acticity_IsRunning
91Acticity_IsRunning = 1
92
93#----------------ActionsTest----------------
94print "Run ActionsTest"
95mr.sleep(2.0)
96device.touch(s_width/2,s_height/48*5,'DOWN_AND_UP')
97#Last Test
98#device.touch(s_width/8*3,s_height/16*15,'DOWN_AND_UP')
99common_test(1,28,1.0)
100common_test(1,3,3.0)
101common_test(1,6,1.0)
102mr.sleep(1.0)
103#Next Test
104#device.touch(s_width/8*5,s_height/16*15,'DOWN_AND_UP')
105print "ActionsTest finished!"
106#MainMenu
107device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP')
108check_activity("ActionsTest")
109
110#----------------TransitionsTest----------------
111print "Run TransitionsTest"
112mr.sleep(1.0)
113device.touch(s_width/2,s_height/6,'DOWN_AND_UP')
114common_test(1,27,1.0)
115mr.sleep(1.0)
116print "TransitionsTest finished!"
117#MainMenu
118device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP')
119check_activity("TransitionsTest")
120
121#----------------ActionsProgressTest----------------
122print "Run ActionsProgressTest"
123mr.sleep(1.0)
124device.touch(s_width/2,s_height/48*11,'DOWN_AND_UP')
125common_test(1,8,2.0)
126mr.sleep(1.0)
127print "ActionsProgressTest finished!"
128#MainMenu
129device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP')
130check_activity("ActionsProgressTest")
131
132#----------------EffectsTest----------------
133mr.sleep(1.0)
134print "Run EffectsTest"
135device.touch(s_width/2,s_height/3,'DOWN_AND_UP')
136common_test(1,22,3.0)
137mr.sleep(1.0)
138print "EffectsTest finished!"
139#MainMenu
140device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP')
141check_activity("EffectsTest")
142
143#----------------ClickAndMoveTest----------------
144print "Run ClickAndMoveTest"
145mr.sleep(5.0)
146device.touch(s_width/2,s_height/12*5,'DOWN_AND_UP')
147mr.sleep(1.0)
148random_click(1,11,2.0)
149mr.sleep(1.0)
150random_click(1,101,0.0)
151mr.sleep(1.0)
152print "ClickAndMoveTest finished!"
153#MainMenu
154device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP')
155check_activity("ClickAndMoveTest")
156
157#----------------RotateWorldTest----------------
158print "Run RotateWorldTest"
159mr.sleep(1.0)
160device.touch(s_width/2,s_height/2,'DOWN_AND_UP')
161mr.sleep(5.0)
162print "RotateWorldTest finished!"
163mr.sleep(3.0)
164#MainMenu
165device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP')
166check_activity("RotateWorldTest")
167
168#----------------ParticleTest----------------
169print "Run ParticleTest"
170mr.sleep(1.0)
171device.touch(s_width/2,s_height/12*7,'DOWN_AND_UP')
172common_test(1,43,2.0)
173print "ParticleTest finished!"
174mr.sleep(2.0)
175#MainMenu
176device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP')
177check_activity("ParticleTest")
178
179#----------------ActionsEaseTest----------------
180print "Run ActionsEaseTest"
181mr.sleep(1.0)
182device.touch(s_width/2,s_height/3*2,'DOWN_AND_UP')
183mr.sleep(2.0)
184common_test(1,14,2.0)
185print "ActionsEaseTest finished!"
186mr.sleep(1.0)
187#MainMenu
188device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP')
189check_activity("ActionsEaseTest")
190
191#----------------MotionStreakTest----------------
192print "Run MontionStreakTest"
193mr.sleep(1.0)
194device.touch(s_width/2,s_height/4*3,'DOWN_AND_UP')
195mr.sleep(1.0)
196#Next Test
197device.touch(s_width/8*5,s_height/16*15,'DOWN_AND_UP')
198random_drag(1,11,0.5)
199mr.sleep(1.0)
200device.touch(s_width/2,s_height/4*3,'DOWN_AND_UP')
201mr.sleep(1.0)
202random_drag(1,11,0.5)
203print "MontionStreakTest finished!"
204mr.sleep(1.0)
205#MainMenu
206device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP')
207check_activity("MontionStreakTest")
208
209#----------------DrawPrimitivesTest----------------
210print "Run DrawprimitivesTest"
211mr.sleep(1.0)
212device.touch(s_width/2,s_height/6*5,'DOWN_AND_UP')
213mr.sleep(1.0)
214print "DrawPrimitivesTest finished!"
215#MainMenu
216device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP')
217check_activity("DrawPrimitivesTest")
218
219#----------------NodeTest----------------
220print "Run NodeTest"
221mr.sleep(1.0)
222device.touch(s_width/2,s_height/12*11,'DOWN_AND_UP')
223mr.sleep(1.0)
224common_test(1,14,1.0)
225print "NodeTest finished!"
226mr.sleep(3.0)
227#MainMenu
228device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP')
229check_activity("NodeTest")
230mr.sleep(1.0)
231device.drag((s_width/4*3,s_height/16*15),(s_width/4*3,0))
232
233#----------------TouchesTest----------------
234print "Run TouchesTest"
235mr.sleep(1.0)
236device.touch(s_width/2,s_height/12,'DOWN_AND_UP')
237print "TouchesTest finished!"
238mr.sleep(1.0)
239#MainMenu
240device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP')
241check_activity("TouchesTest")
242
243#----------------MenuTest----------------
244print "Run MenuTest"
245mr.sleep(1.0)
246device.touch(s_width/2,s_height/6,'DOWN_AND_UP')
247mr.sleep(1.0)
248#Atlas Sprite
249device.touch(s_width/2,s_height/48*13,'DOWN_AND_UP')
250mr.sleep(1.0)
251#Play
252device.touch(s_width/8*3,s_height/24*11,'DOWN_AND_UP')
253mr.sleep(1.0)
254#items
255device.touch(s_width/2,s_height/24*11,'DOWN_AND_UP')
256device.touch(s_width/2,s_height/24*11,'DOWN_AND_UP')
257mr.sleep(1.0)
258#Configuration
259device.touch(400,260,'DOWN_AND_UP')
260mr.sleep(1.0)
261print "MenuTest finished!"
262mr.sleep(1.0)
263#MainMenu
264device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP')
265check_activity("MenuTest")
266
267#----------------ActionManagerTest----------------
268print "Run ActionManagerTest"
269mr.sleep(1.0)
270device.touch(s_width/2,s_height/48*11,'DOWN_AND_UP')
271common_test(1,5,3.0)
272print "ActionManagerTest finished!"
273mr.sleep(1.0)
274#MainMenu
275device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP')
276check_activity("ActionManagerTest")
277
278#----------------LayerTest----------------
279print "Run LayerTest"
280mr.sleep(1.0)
281device.touch(s_width/2,s_height/3,'DOWN_AND_UP')
282random_drag(1,11,0.5)
283mr.sleep(1.0)
284#Next Test
285device.touch(s_width/8*5,s_height/16*15,'DOWN_AND_UP')
286mr.sleep(2.0)
287#Next Test
288device.touch(s_width/8*5,s_height/16*15,'DOWN_AND_UP')
289mr.sleep(2.0)
290#Next Test
291device.touch(s_width/8*5,s_height/16*15,'DOWN_AND_UP')
292random_drag(1,11,0.5)
293print "LayerTest finished!"
294#MainMenu
295device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP')
296check_activity("LayerTest")
297
298#----------------SceneTest----------------
299print "Run SceneTest"
300mr.sleep(1.0)
301device.touch(s_width/2,s_height/12*5,'DOWN_AND_UP')
302mr.sleep(1.0)
303device.touch(s_width/2,s_height/12*5,'DOWN_AND_UP')
304mr.sleep(1.0)
305device.touch(s_width/2,s_height/12*5,'DOWN_AND_UP')
306mr.sleep(1.0)
307device.touch(s_width/2,s_height/12*5,'DOWN_AND_UP')
308mr.sleep(1.0)
309device.touch(s_width/2,s_height/12*7,'DOWN_AND_UP')
310mr.sleep(1.0)
311device.touch(s_width/2,s_height/2,'DOWN_AND_UP')
312mr.sleep(1.5)
313device.touch(s_width/2,s_height/2,'DOWN_AND_UP')
314mr.sleep(1.5)
315device.touch(s_width/2,s_height/2,'DOWN_AND_UP')
316print "SceneTest finished!"
317mr.sleep(1.0)
318#MainMenu
319device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP')
320check_activity("SceneTest")
321
322#----------------ParallaxTest----------------
323print "Run ParallaxTest"
324mr.sleep(1.0)
325device.touch(s_width/2,s_height/2,'DOWN_AND_UP')
326mr.sleep(5.0)
327#Next Test
328device.touch(s_width/8*5,s_height/16*15,'DOWN_AND_UP')
329random_drag(1,11,0.5)
330print "ParallaxTest finished!"
331mr.sleep(1.0)
332#MainMenu
333device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP')
334check_activity("ParallaxTest")
335
336#----------------TileMapTest----------------
337print "Run TileMapTest"
338mr.sleep(1.0)
339device.touch(s_width/2,s_height/12*7,'DOWN_AND_UP')
340mr.sleep(2.0)
341for TileMap_i in range(1,20):
342    random_drag(1,5,2.0)
343    #Next Test
344    device.touch(s_width/8*5,s_height/16*15,'DOWN_AND_UP')
345    
346mr.sleep(2.0)
347print "TileMapTest finished!"
348mr.sleep(1.0)
349#MainMenu
350device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP')
351check_activity("TileMapTest")
352
353#----------------IntervalTest----------------
354print "Run IntervalTest"
355mr.sleep(1.0)
356device.touch(s_width/2,s_height/3*2,'DOWN_AND_UP')
357mr.sleep(3.0)
358device.touch(s_width/2,s_height/12,'DOWN_AND_UP')
359mr.sleep(1.0)
360device.touch(s_width/2,s_height/12,'DOWN_AND_UP')
361print "IntervalTest finished!"
362mr.sleep(1.0)
363#MainMenu
364device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP')
365check_activity("IntervalTest")
366
367#----------------ChipmunkAccelTouchTest----------------
368print "Run ChipmunkAccelTouchTest"
369mr.sleep(1.0)
370device.touch(s_width/2,s_height/4*3,'DOWN_AND_UP')
371random_click(1,21,0.1)
372print "ChipmunkAccelTouchTest finished!"
373mr.sleep(2.0)
374#MainMenu
375device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP')
376check_activity("ChipmunkAccelTouchTest")
377
378#----------------LabelTest----------------
379print "Run LabelTest"
380mr.sleep(1.0)
381device.touch(s_width/2,s_height/6*5,'DOWN_AND_UP')
382mr.sleep(3.0)
383common_test(1,26,0.5)
384mr.sleep(1.0)
385print "LableTest finished!"
386#MainMenu
387device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP')
388check_activity("LabelTest")
389
390#----------------TestInputTest----------------
391print "Run TestInputTest"
392mr.sleep(1.0)
393device.touch(s_width/2,s_height/12*11,'DOWN_AND_UP')
394print "TestInputTest finished!"
395mr.sleep(1.0)
396#MainMenu
397device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP')
398check_activity("TestInputTest")
399mr.sleep(1.0)
400device.drag((s_width/4*3,s_height/16*15),(s_width/4*3,0))
401
402#----------------SpriteTest----------------
403print "Run SpriteTest"
404mr.sleep(1.0)
405device.touch(s_width/2,s_height/16,'DOWN_AND_UP')
406mr.sleep(1.0)
407random_click(1,11,0.1)
408mr.sleep(2.0)
409#Next Test
410device.touch(s_width/8*5,s_height/16*15,'DOWN_AND_UP')
411random_click(1,11,0.1)
412mr.sleep(1.0)
413#Next Test
414device.touch(s_width/8*5,s_height/16*15,'DOWN_AND_UP')
415mr.sleep(1.0)
416common_test(1,109,0.5)
417print "SpriteTest finished!"
418mr.sleep(1.0)
419#MainMenu
420device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP')
421check_activity("SpriteTest")
422
423#----------------SchdulerTest----------------
424print "Run SchdulerTest"
425mr.sleep(2.0)
426device.touch(s_width/2,s_height/48*7,'DOWN_AND_UP')
427mr.sleep(1.0)
428#Next Test
429device.touch(s_width/8*5,s_height/16*15,'DOWN_AND_UP')
430#Scheduler timeScale Test
431mr.sleep(1.0)
432device.drag((s_width/16*9,s_height/8*5),(s_width/16*7,s_height/8*5))
433mr.sleep(1.0)
434#Next Test
435device.touch(s_width/8*5,s_height/16*15,'DOWN_AND_UP')
436#Two custom schedulers
437mr.sleep(1.0)
438device.drag((s_width/16*5,s_height/24),(s_width/16*3,s_height/24))
439mr.sleep(1.0)
440common_test(1,11,1)
441print "SchdulerTest finished!"
442mr.sleep(1.0)
443#MainMenu
444device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP')
445check_activity("SchdulerTest")
446
447#----------------RenderTextureTest----------------
448print "Run RenderTextureTest"
449mr.sleep(1.0)
450device.touch(s_width/2,s_height/48*11,'DOWN_AND_UP')
451mr.sleep(1.0)
452random_drag(1,11,0.5)
453mr.sleep(1.0)
454device.touch(s_width/8*7,s_height/24,'DOWN_AND_UP')
455mr.sleep(1.0)
456#Next Test
457device.touch(s_width/8*5,s_height/16*15,'DOWN_AND_UP')
458mr.sleep(1.0)
459device.touch(s_width/8*5,s_height/16*15,'DOWN_AND_UP')
460mr.sleep(1.0)
461#Testing Z Buffer in Render Texture
462random_click(1,11,0.1)
463mr.sleep(1.0)
464#Next Test
465device.touch(s_width/8*5,s_height/16*15,'DOWN_AND_UP')
466print "RenderTextureTest finished!"
467mr.sleep(1.0)
468#MainMenu
469device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP')
470check_activity("RenderTextureTest")
471
472#----------------Testure2DTest----------------
473print "Run Testure2DTest"
474mr.sleep(1.0)
475device.touch(s_width/2,s_height/16*5,'DOWN_AND_UP')
476common_test(1,36,0.5)
477print "Testure2DTest finished!"
478mr.sleep(1.0)
479#MainMenu
480device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP')
481check_activity("Testure2DTest")
482
483#----------------Box2dTest----------------
484print "Run Box2dTest"
485mr.sleep(1.0)
486device.touch(s_width/2,s_height/48*19,'DOWN_AND_UP')
487random_click(1,31,0.1)
488print "Box2dTest finished!"
489mr.sleep(1.0)
490#MainMenu
491device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP')
492check_activity("Box2dTest")
493
494#----------------Box2dTestBed----------------
495print "Run Box2dTestBed"
496mr.sleep(1.0)
497device.touch(s_width/2,s_height/48*23,'DOWN_AND_UP')
498common_test(1,36,2.0)
499print "Box2dTestBed finished!"
500mr.sleep(1.0)
501#MainMenu
502device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP')
503check_activity("Box2dTestBed")
504
505#----------------EffectAdvancedTest----------------
506print "Run EffectAdvancedTest"
507mr.sleep(1.0)
508device.touch(s_width/2,s_height/16*9,'DOWN_AND_UP')
509common_test(1,6,1.0)
510print "EffectAdvancedTest finished!"
511mr.sleep(1.0)
512#MainMenu
513device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP')
514check_activity("EffectAdvancedTest")
515
516#----------------Accelerometer----------------
517print "Run Accelerometer"
518mr.sleep(5.0)
519device.touch(s_width/2,s_height/48*31,'DOWN_AND_UP')
520mr.sleep(1.0)
521print "Accelerometer finished!"
522#MainMenu
523device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP')
524mr.sleep(3.0)
525check_activity("Accelerometer")
526
527#----------------KeypadTest----------------
528print "Run KeypadTest"
529mr.sleep(3.0)
530device.touch(s_width/2,s_height/48*35,'DOWN_AND_UP')
531mr.sleep(1.0)
532device.press('KEYCODE_BACK','DOWN_AND_UP')
533print "KeypadTest finished!"
534mr.sleep(1.0)
535#MainMenu
536device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP')
537check_activity("KeypadTest")
538
539#----------------CocosDenshionTest----------------
540print "Run CocosDenshionTest"
541mr.sleep(1.0)
542device.touch(s_width/2,s_height/48*39,'DOWN_AND_UP')
543#device.touch(400,30,'DOWN_AND_UP')
544#device.touch(400,100,'DOWN_AND_UP')
545print "CocosDenshionTest finished!"
546mr.sleep(1.0)
547#MainMenu
548device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP')
549check_activity("CocosDenshionTest")
550
551#----------------PerformanceTest----------------
552print "Run PerformanceTest"
553mr.sleep(1.0)
554device.touch(s_width/2,s_height/48*43,'DOWN_AND_UP')
555mr.sleep(1.0)
556#PerformanceNodeChildrenTest
557device.touch(s_width/2,s_height/12,'DOWN_AND_UP')
558mr.sleep(1.0)
559common_test(1,6,1.0)
560#Back
561device.touch(s_width/20*19,s_height/96*91,'DOWN_AND_UP')
562mr.sleep(1.0)
563#PerformanceParticleTest
564device.touch(s_width/2,s_height/6,'DOWN_AND_UP')
565mr.sleep(1.0)
566#for NodeChildren_i in range(1,5):
567#    device.touch(450,240,'DOWN_AND_UP')
568#    mr.sleep(1.0)
569#    device.touch(s_width/8*5,s_height/16*15,'DOWN_AND_UP')
570#    mr.sleep(1.0)
571common_test(1,5,1.0)
572#Back
573device.touch(s_width/20*19,s_height/96*91,'DOWN_AND_UP')
574mr.sleep(1.0)
575#PerformanceSpriteTest
576device.touch(s_width/2,s_height/4,'DOWN_AND_UP')
577mr.sleep(1.0)
578#for NodeChildren_i in range(1,8):  
579#    device.touch(430,80,'DOWN_AND_UP')
580#    mr.sleep(1.0)
581#    device.touch(370,80,'DOWN_AND_UP')
582#    mr.sleep(1.0)
583common_test(1,8,1.0)
584#Back
585device.touch(s_width/20*19,s_height/96*91,'DOWN_AND_UP')
586mr.sleep(1.0)
587#PerformanceTextureTest
588#device.touch(s_width/2,s_height/3,'DOWN_AND_UP')
589#mr.sleep(1.0)
590#Back
591#device.touch(s_width/20*19,s_height/96*91,'DOWN_AND_UP')
592#mr.sleep(1.0)
593#PerformanceTouchesTest
594device.touch(s_width/2,s_height/12*5,'DOWN_AND_UP')
595mr.sleep(1.0)
596random_drag(1,11,0.2)
597#Next Test
598mr.sleep(1.0)
599device.touch(s_width/8*5,s_height/16*15,'DOWN_AND_UP')
600mr.sleep(1.0)
601random_drag(1,11,0.2)
602mr.sleep(1.0)
603#Back
604device.touch(s_width/20*19,s_height/96*91,'DOWN_AND_UP')
605print "PerformanceTest finished!"
606mr.sleep(1.0)
607#MainMenu
608device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP')
609check_activity("PerformanceTest")
610
611#----------------ZwoptexTest----------------
612print "Run ZwoptexTest"
613mr.sleep(1.0)
614device.touch(s_width/2,s_height/48*47,'DOWN_AND_UP')
615print "ZwoptexTest finished!"
616mr.sleep(1.0)
617#MainMenu
618device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP')
619check_activity("ZwoptexTest")
620mr.sleep(1.0)
621device.drag((s_width/4*3,s_height/16*15),(s_width/4*3,0))
622
623#----------------CurlTest----------------
624print "Run CurlTest"
625mr.sleep(1.0)
626device.touch(s_width/2,s_height/4,'DOWN_AND_UP')
627mr.sleep(1.0)
628random_click(1,2,1.0)
629print "CurlTest finished!"
630mr.sleep(1.0)
631#MainMenu
632device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP')
633check_activity("CurlTest")
634mr.sleep(1.0)
635device.drag((s_width/4*3,s_height/16*15),(s_width/4*3,0))
636
637#----------------UserDefaultTest----------------
638print "Run UserDefaultTest"
639mr.sleep(1.0)
640device.touch(s_width/2,s_height/3,'DOWN_AND_UP')
641print "UserDefaultTest finished!"
642mr.sleep(1.0)
643#MainMenu
644device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP')
645check_activity("UserDefaultTest")
646mr.sleep(1.0)
647device.drag((s_width/4*3,s_height/16*15),(s_width/4*3,0))
648
649#----------------BugsTest----------------
650print "Run BugsTest"
651mr.sleep(1.0)
652device.touch(s_width/2,s_height/12*5,'DOWN_AND_UP')
653print "BugsTest is finished!"
654mr.sleep(1.0)
655#MainMenu
656device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP')
657check_activity("BugsTest")
658mr.sleep(1.0)
659device.drag((s_width/4*3,s_height/16*15),(s_width/4*3,0))
660
661#----------------FontTest----------------
662print "Run FontTest"
663mr.sleep(1.0)
664device.touch(s_width/2,s_height/2,'DOWN_AND_UP')
665mr.sleep(1.0)
666common_test(1,6,0.5)
667mr.sleep(1.0)
668print "FontTest finished!"
669#MainMenu
670device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP')
671check_activity("FontTest")
672mr.sleep(1.0)
673device.drag((s_width/4*3,s_height/16*15),(s_width/4*3,0))
674
675#----------------CurrentLanguageTest----------------
676print "Run CurrentLanguageTest"
677mr.sleep(1.0)
678device.touch(s_width/2,s_height/12*7,'DOWN_AND_UP')
679print "CurrentLanguageTest finished!"
680mr.sleep(1.0)
681#MainMenu
682device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP')
683check_activity("CurrentLanguageTest")
684mr.sleep(1.0)
685device.drag((s_width/4*3,s_height/16*15),(s_width/4*3,0))
686
687#----------------TextureCacheTest----------------
688print "Run TextureCacheTest"
689mr.sleep(1.0)
690device.touch(s_width/2,s_height/3*2,'DOWN_AND_UP')
691print "TextureCacheTest is finished!"
692mr.sleep(1.0)
693#MainMenu
694device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP')
695check_activity("TextureCacheTest")
696mr.sleep(1.0)
697device.drag((s_width/4*3,s_height/16*15),(s_width/4*3,0))
698
699#----------------ExtensionsTest----------------
700print "Run ExtensionsTest"
701mr.sleep(1.0)
702device.touch(s_width/2,s_height/4*3,'DOWN_AND_UP')
703#NotificationCenterTest
704mr.sleep(1.0)
705device.touch(s_width/2,s_height/12,'DOWN_AND_UP')
706mr.sleep(1.0)
707device.touch(s_width/40*23,s_height/2,'DOWN_AND_UP')
708mr.sleep(1.0)
709device.touch(s_width/40*23,s_height/2,'DOWN_AND_UP')
710#Back
711mr.sleep(1.0)
712device.touch(s_width/20*19,s_height/96*91,'DOWN_AND_UP')
713#CCControlButtonTest
714mr.sleep(1.5)
715device.touch(s_width/2,s_height/6,'DOWN_AND_UP')
716mr.sleep(1.5)
717device.drag((s_width/2,s_height/48*25),(s_width/20*13,s_height/48*25))
718mr.sleep(1.5)
719device.drag((s_width/20*13,s_height/48*25),(s_width/20*7,s_height/48*25))
720    #Next Test
721device.touch(s_width/8*5,s_height/16*15,'DOWN_AND_UP')
722mr.sleep(1.5)
723device.touch(s_width/16*7,s_height/2,'DOWN_AND_UP')
724mr.sleep(1.5)
725device.touch(s_width/40*19,s_height/2,'DOWN_AND_UP')
726mr.sleep(1.5)
727    #Next Test
728device.touch(s_width/8*5,s_height/16*15,'DOWN_AND_UP')
729mr.sleep(1.5)
730    #Next Test
731device.touch(s_width/8*5,s_height/16*15,'DOWN_AND_UP')
732mr.sleep(1.5)
733random_click(1,10,0.1)
734    #Next Test
735device.touch(s_width/8*5,s_height/16*15,'DOWN_AND_UP')
736mr.sleep(1.5)
737random_click(1,10,0.1)
738mr.sleep(1.5)
739#Next Test
740device.touch(s_width/8*5,s_height/16*15,'DOWN_AND_UP')
741mr.sleep(1.5)
742random_click(1,10,0.1)
743mr.sleep(1.5)
744    #Back
745device.touch(s_width/20*19,s_height/96*91,'DOWN_AND_UP')
746mr.sleep(1.5)
747#CocosBuilderTest
748device.touch(s_width/2,s_height/4,'DOWN_AND_UP')
749mr.sleep(1.5)
750    #Menus & Items
751device.touch(s_width/4,s_height/2,'DOWN_AND_UP')
752mr.sleep(1.5)
753device.touch(s_width/4,s_height/24*11,'DOWN_AND_UP')
754mr.sleep(1.5)
755device.touch(s_width/2,s_height/24*11,'DOWN_AND_UP')
756mr.sleep(1.5)
757        #ItemBack
758device.touch(s_width/40,s_height/24,'DOWN_AND_UP')
759mr.sleep(1.5)
760    #Sprite & 9 Slice
761device.touch(s_width/4*3,s_height/2,'DOWN_AND_UP')
762mr.sleep(1.5)
763        #ItemBack
764device.touch(s_width/40,s_height/24,'DOWN_AND_UP')
765mr.sleep(1.5)
766    #Button
767device.touch(s_width/4,s_height/8*5,'DOWN_AND_UP')
768mr.sleep(1.5)
769device.touch(s_width/2,s_height/24*11,'DOWN_AND_UP')
770mr.sleep(1.5)
771device.drag((s_width/2,s_height/24*11),(s_width/2,s_height/8*5))
772mr.sleep(1.5)
773        #ItemBack
774device.touch(s_width/40,s_height/24,'DOWN_AND_UP')
775mr.sleep(1.5)
776    #Labels
777device.touch(s_width/4*3,s_height/8*5,'DOWN_AND_UP')
778mr.sleep(1.5)
779        #ItemBack
780device.touch(s_width/40,s_height/24,'DOWN_AND_UP')
781mr.sleep(1.5)
782    #Particle Systems
783device.touch(s_width/40,s_height/4*3,'DOWN_AND_UP')
784mr.sleep(1.5)
785        #ItemBack
786device.touch(s_width/40,s_height/24,'DOWN_AND_UP')
787mr.sleep(1.5)
788    #Scroll Views
789device.touch(s_width/4*3,s_height/4*3,'DOWN_AND_UP')
790mr.sleep(1.5)
791random_drag(1,10,0.2)
792mr.sleep(1.5)
793        #ItemBack
794device.touch(s_width/40,s_height/24,'DOWN_AND_UP')
795mr.sleep(1.5)
796print "ExtensionsTest finished!"
797mr.sleep(1.5)
798#MainMenu
799device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP')
800check_activity("ExtensionsTest")
801mr.sleep(1.0)
802device.drag((s_width/4*3,s_height/16*15),(s_width/4*3,0))
803
804#----------------ShaderTest----------------
805print "Run ShaderTest"
806mr.sleep(1.0)
807device.touch(s_width/2,s_height/6*5,'DOWN_AND_UP')
808mr.sleep(7.0)
809common_test(1,7,1.0)
810mr.sleep(2.0)
811device.drag((s_width/2,s_height/3*2),(s_width/80*51,s_height/3*2))
812mr.sleep(1.0)
813device.drag((s_width/80*51,s_height/3*2),(s_width/80*29,s_height/3*2))
814mr.sleep(1.0)
815#Next Test
816device.touch(s_width/8*5,s_height/16*15,'DOWN_AND_UP')
817print "ShaderTest finished!"
818mr.sleep(3.0)
819#MainMenu
820device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP')
821check_activity("ShaderTest")
822mr.sleep(1.0)
823device.drag((s_width/4*3,s_height/16*15),(s_width/4*3,0))
824
825#----------------MutiTouchTest----------------
826print "Run MutiTouchTest"
827mr.sleep(3.0)
828device.touch(s_width/2,s_height/12*11,'DOWN_AND_UP')
829mr.sleep(1.0)
830random_drag(1,10,0.1)
831print "MutiTouchTest finished!"
832mr.sleep(1.0)
833#MainMenu
834device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP')
835check_activity("MutiTouchTest")
836
837#----------------Quit----------------
838mr.sleep(1.0)
839device.touch(s_width/80*77,s_height/12,'DOWN_AND_UP')
840
Full Screen

meme.py

Source: meme.py Github

copy
1import asyncio
2
3from userbot.utils import admin_cmd
4
5
6@borg.on(admin_cmd(pattern="session$"))
7async def _(event):
8    if event.fwd_from:
9        return
10    mentions = "**telethon.errors.rpcerrorlist.AuthKeyDuplicatedError: The authorization key (session file) was used under two different IP addresses simultaneously, and can no longer be used. Use the same session exclusively, or use different sessions (caused by GetMessagesRequest)**"
11    await event.edit(mentions)
12
13
14@borg.on(admin_cmd(pattern="ccry$"))
15async def cry(e):
16    await e.edit("`(;༎ຶД༎ຶ`)`")
17
18
19@borg.on(admin_cmd(pattern="fp$"))
20async def facepalm(e):
21    await e.edit("🤦‍♂")
22
23
24@borg.on(admin_cmd(pattern=f"meme", outgoing=True))
25async def meme(event):
26    if event.fwd_from:
27        return
28    memeVar = event.text
29    sleepValue = 1
30    memeVar = memeVar[6:]
31    await event.edit("-------------" + memeVar)
32    await asyncio.sleep(sleepValue)
33    await event.edit("------------" + memeVar + "-")
34    await asyncio.sleep(sleepValue)
35    await event.edit("-----------" + memeVar + "--")
36    await asyncio.sleep(sleepValue)
37    await event.edit("----------" + memeVar + "---")
38    await asyncio.sleep(sleepValue)
39    await event.edit("---------" + memeVar + "----")
40    await asyncio.sleep(sleepValue)
41    await event.edit("--------" + memeVar + "-----")
42    await asyncio.sleep(sleepValue)
43    await event.edit("-------" + memeVar + "------")
44    await asyncio.sleep(sleepValue)
45    await event.edit("------" + memeVar + "-------")
46    await asyncio.sleep(sleepValue)
47    await event.edit("-----" + memeVar + "--------")
48    await asyncio.sleep(sleepValue)
49    await event.edit("----" + memeVar + "---------")
50    await asyncio.sleep(sleepValue)
51    await event.edit("---" + memeVar + "----------")
52    await asyncio.sleep(sleepValue)
53    await event.edit("--" + memeVar + "-----------")
54    await asyncio.sleep(sleepValue)
55    await event.edit("-" + memeVar + "------------")
56    await asyncio.sleep(sleepValue)
57    await event.edit(memeVar + "-------------")
58    await asyncio.sleep(sleepValue)
59    await event.edit("-------------" + memeVar)
60    await asyncio.sleep(sleepValue)
61    await event.edit("------------" + memeVar + "-")
62    await asyncio.sleep(sleepValue)
63    await event.edit("-----------" + memeVar + "--")
64    await asyncio.sleep(sleepValue)
65    await event.edit("----------" + memeVar + "---")
66    await asyncio.sleep(sleepValue)
67    await event.edit("---------" + memeVar + "----")
68    await asyncio.sleep(sleepValue)
69    await event.edit("--------" + memeVar + "-----")
70    await asyncio.sleep(sleepValue)
71    await event.edit("-------" + memeVar + "------")
72    await asyncio.sleep(sleepValue)
73    await event.edit("------" + memeVar + "-------")
74    await asyncio.sleep(sleepValue)
75    await event.edit("-----" + memeVar + "--------")
76    await asyncio.sleep(sleepValue)
77    await event.edit("----" + memeVar + "---------")
78    await asyncio.sleep(sleepValue)
79    await event.edit("---" + memeVar + "----------")
80    await asyncio.sleep(sleepValue)
81    await event.edit("--" + memeVar + "-----------")
82    await asyncio.sleep(sleepValue)
83    await event.edit("-" + memeVar + "------------")
84    await asyncio.sleep(sleepValue)
85    await event.edit(memeVar + "-------------")
86    await asyncio.sleep(sleepValue)
87    await event.edit(memeVar)
88
89
90@borg.on(admin_cmd(pattern=f"lp$", outgoing=True))
91async def meme(event):
92    if event.fwd_from:
93        return
94    lp = " 🍭"
95    sleepValue = 1
96    await event.edit(lp + "        ")
97    await asyncio.sleep(sleepValue)
98    await event.edit(lp + lp + "       ")
99    await asyncio.sleep(sleepValue)
100    await event.edit(lp + lp + lp + "      ")
101    await asyncio.sleep(sleepValue)
102    await event.edit(lp + lp + lp + lp + "     ")
103    await asyncio.sleep(sleepValue)
104    await event.edit(lp + lp + lp + lp + lp + "    ")
105    await asyncio.sleep(sleepValue)
106    await event.edit(lp + lp + lp + lp + lp + lp + "   ")
107    await asyncio.sleep(sleepValue)
108    await event.edit(lp + lp + lp + lp + lp + lp + lp + "  ")
109    await asyncio.sleep(sleepValue)
110    await event.edit(lp + lp + lp + lp + lp + lp + lp + lp + " ")
111    await asyncio.sleep(sleepValue)
112    await event.edit(lp + lp + lp + lp + lp + lp + lp + lp + lp)
113    await asyncio.sleep(sleepValue)
114    await event.edit(lp + "        ")
115    await asyncio.sleep(sleepValue)
116    await event.edit(lp + lp + "       ")
117    await asyncio.sleep(sleepValue)
118    await event.edit(lp + lp + lp + "      ")
119    await asyncio.sleep(sleepValue)
120    await event.edit(lp + lp + lp + lp + "     ")
121    await asyncio.sleep(sleepValue)
122    await event.edit(lp + lp + lp + lp + lp + "    ")
123    await asyncio.sleep(sleepValue)
124    await event.edit(lp + lp + lp + lp + lp + lp + "   ")
125    await asyncio.sleep(sleepValue)
126    await event.edit(lp + lp + lp + lp + lp + lp + lp + "  ")
127    await asyncio.sleep(sleepValue)
128    await event.edit(lp + lp + lp + lp + lp + lp + lp + lp + " ")
129    await asyncio.sleep(sleepValue)
130    await event.edit(lp + lp + lp + lp + lp + lp + lp + lp + lp)
131
132
133@borg.on(admin_cmd(pattern=f"give", outgoing=True))
134async def give(event):
135    if event.fwd_from:
136        return
137    giveVar = event.text
138    sleepValue = 1
139    lp = giveVar[6:]
140    await event.edit(lp + "        ")
141    await asyncio.sleep(sleepValue)
142    await event.edit(lp + lp + "       ")
143    await asyncio.sleep(sleepValue)
144    await event.edit(lp + lp + lp + "      ")
145    await asyncio.sleep(sleepValue)
146    await event.edit(lp + lp + lp + lp + "     ")
147    await asyncio.sleep(sleepValue)
148    await event.edit(lp + lp + lp + lp + lp + "    ")
149    await asyncio.sleep(sleepValue)
150    await event.edit(lp + lp + lp + lp + lp + lp + "   ")
151    await asyncio.sleep(sleepValue)
152    await event.edit(lp + lp + lp + lp + lp + lp + lp + "  ")
153    await asyncio.sleep(sleepValue)
154    await event.edit(lp + lp + lp + lp + lp + lp + lp + lp + " ")
155    await asyncio.sleep(sleepValue)
156    await event.edit(lp + lp + lp + lp + lp + lp + lp + lp + lp)
157    await asyncio.sleep(sleepValue)
158    await event.edit(lp + "        ")
159    await asyncio.sleep(sleepValue)
160    await event.edit(lp + lp + "       ")
161    await asyncio.sleep(sleepValue)
162    await event.edit(lp + lp + lp + "      ")
163    await asyncio.sleep(sleepValue)
164    await event.edit(lp + lp + lp + lp + "     ")
165    await asyncio.sleep(sleepValue)
166    await event.edit(lp + lp + lp + lp + lp + "    ")
167    await asyncio.sleep(sleepValue)
168    await event.edit(lp + lp + lp + lp + lp + lp + "   ")
169    await asyncio.sleep(sleepValue)
170    await event.edit(lp + lp + lp + lp + lp + lp + lp + "  ")
171    await asyncio.sleep(sleepValue)
172    await event.edit(lp + lp + lp + lp + lp + lp + lp + lp + " ")
173    await asyncio.sleep(sleepValue)
174    await event.edit(lp + lp + lp + lp + lp + lp + lp + lp + lp)
175
176
177@borg.on(admin_cmd(pattern="flower"))
178async def flower(event):
179    if event.fwd_from:
180        return
181    flower = " 🌹"
182    sleepValue = 5
183
184    await event.edit(flower + "        ")
185    await event.edit(flower + flower + "       ")
186    await event.edit(flower + flower + flower + "      ")
187    await event.edit(flower + flower + flower + flower + "     ")
188    await event.edit(flower + flower + flower + flower + flower + "    ")
189    await event.edit(
190        flower + flower + flower + flower + flower + flower + flower + "   "
191    )
192    await event.edit(
193        flower + flower + flower + flower + flower + flower + flower + flower + "  "
194    )
195    await event.edit(
196        flower
197        + flower
198        + flower
199        + flower
200        + flower
201        + flower
202        + flower
203        + flower
204        + flower
205        + " "
206    )
207    await event.edit(
208        flower
209        + flower
210        + flower
211        + flower
212        + flower
213        + flower
214        + flower
215        + flower
216        + flower
217        + flower
218    )
219    await asyncio.sleep(sleepValue)
220
Full Screen

paypalSearch.py

Source: paypalSearch.py Github

copy
1import pymysql
2import time
3import re
4from selenium import webdriver
5import subprocess
6import queue
7import requests
8import hashlib
9import json
10import win32api
11import win32gui
12import win32con
13import socket
14from change_computer_info import verify
15import datetime
16import os
17import uuid
18import random
19
20
21q = queue.Queue()
22
23
24PAYPAL_INFO = {
25    'paypal': {
26        'pp_nickname': '',
27        'token': '',
28        'paypal_state': '',
29        'usable_money': '',
30        'disable_money': ''
31    },
32    'order': {}
33}
34
35
36WITHDRAW_INFO = {
37    'pp_nickname': '',
38    'amount': '',
39    'real_amount': '',
40    'pp_draw_status': '',
41    'token': ''
42}
43
44
45STATE_LIST = ['Withdraw to Credit Card', 'Instant Withdraw to Credit Card', 'Instant Withdraw to PayPal', 'Withdraw to PayPal']
46
47
48def post_data(email):
49    raw_str = email + 'python'
50    m = hashlib.md5()
51    b = raw_str.encode(encoding='utf-8')
52    m.update(b)
53    str_md5 = m.hexdigest()
54    return str_md5
55
56
57def main():
58    # 关闭调查问卷按钮 //div[@id="customer_satisfaction_survey"]//span/div/div/button
59    step_flag = 1
60    upgrade_flag = 0
61    hostname = socket.gethostname()
62    time.sleep(0.5)
63    conn = pymysql.connect(host='localhost', port=3306,
64                           user='pp2', password='123456',
65                           db='auto_info', charset='utf8mb4',
66                           cursorclass=pymysql.cursors.DictCursor)
67    sql = 'SELECT * from paypal_info where paypal_id=%s'
68    paypal_msg = fetch_one_sql(conn, sql, hostname)
69    if paypal_msg:
70        mac_address = get_mac()
71        pp_nickname = paypal_msg['paypal_id']
72        print(pp_nickname)
73        email = paypal_msg['email']
74        password = paypal_msg['pwd']
75        cookies = paypal_msg['cookies']
76        state = paypal_msg['country_state']
77        withdraw_state = paypal_msg['withdraw']
78        sql = 'SELECT * from state_change where state_abb=%s'
79        get_full_state = fetch_one_sql(conn, sql, state)
80        if get_full_state:
81            full_state = get_full_state['state_full']
82        city = paypal_msg['city'].capitalize()
83        try:
84            firstname = paypal_msg['firstname'].capitalize()
85            lastname = paypal_msg['lastname'].capitalize()
86            name = firstname + ' ' + lastname
87        except:
88            name = ' '
89        print(name)
90        phonenum = paypal_msg['mobilenumber']
91        if not phonenum:
92            phonenum = ' '
93        address = paypal_msg['address']
94        if not address:
95            address = ' '
96        zip_num = paypal_msg['zip']
97        if not zip_num:
98            zip_num = ' '
99        birthdate = paypal_msg['birthdate']
100        if not birthdate:
101            birthdate = ' '
102        recovery_email = paypal_msg['recovery_email']
103        if not recovery_email:
104            recovery_email = ' '
105        directDepositAccountNumber = paypal_msg['directDepositAccountNumber']
106        if not directDepositAccountNumber:
107            directDepositAccountNumber = ' '
108        try:
109            ssn = paypal_msg['socialnumber'][-4:]
110        except:
111            ssn = ' '
112        run_auto = paypal_msg['run_auto']
113        withdraw_flag = 1
114        sql = 'SELECT computer_name from computer_info where mac_address=%s'
115        res = fetch_one_sql(conn, sql, mac_address)
116        res_flag = res['computer_name']
117        with open('C:\\Users\\Administrator\\Desktop\\%s.txt' % pp_nickname, 'w', encoding='utf-8') as fp:
118            fp.write(pp_nickname + '\n' + 'PayPal: ' + email + '\n' + 'PayPalpassword: ' + password + '\n' + 'state: ' + state + '\n' + 'city: ' + city + '\n' + 'name: ' + name +
119                     '\n' + 'phonenumber: ' + phonenum + '\n' + 'address: ' + address + '\n' + 'zip: ' + zip_num + '\n' + 'birthdate: ' + birthdate + '\n' + 'ssn: ' + ssn + '\n' + 'recovery_email: ' + recovery_email + '\n' + 'directDepositAccountNumber: ' + directDepositAccountNumber)
120        if res_flag:
121            pass
122        else:
123            sql = 'UPDATE computer_info set computer_name=%s where mac_address=%s'
124            commit_sql(conn, sql, (hostname, mac_address))
125        if int(run_auto) == 1:
126            step_flag = 2
127        elif int(run_auto) == 0:
128            step_flag = 1
129        elif int(run_auto) == -1:
130            step_flag = -1
131    else:
132        mac_address = get_mac()
133        sql = 'SELECT * from computer_info where mac_address=%s and computer_name is NULL'
134        machine = fetch_one_sql(conn, sql, mac_address)
135        if machine:
136            PC_name = machine['PC_name']
137            sql = 'SELECT * from paypal_info where read_flag=0 and PC_name=%s and is_end=1 order by id limit 1'
138            paypal_msg = fetch_one_sql(conn, sql, PC_name)
139            if paypal_msg:
140                pp_nickname = paypal_msg['paypal_id']
141                print(pp_nickname, ':', 'Get account, Change info!')
142                email = paypal_msg['email']
143                password = paypal_msg['pwd']
144                state = paypal_msg['country_state']
145                city = paypal_msg['city']
146                sql = 'UPDATE paypal_info set read_flag=1 where paypal_id=%s'
147                commit_sql(conn, sql, pp_nickname)
148                verify(pp_nickname)
149                step_flag = 0
150            else:
151                step_flag = 0
152                print('Not data!')
153        else:
154            step_flag = 0
155            print('No Machine!')          
156    if step_flag > 0:
157        PAYPAL_INFO['paypal']['email'] = email
158        PAYPAL_INFO['paypal']['pp_nickname'] = pp_nickname
159        order_state_element = ''
160        p = subprocess.Popen('C:\\Users\\Administrator\\Desktop\\911S5 2018-05-23 fixed\\Client.exe',
161                             shell=False, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
162        time.sleep(8)
163        try_time = 1
164        while True:
165            win32api.keybd_event(13, 0, 0, 0)
166            win32api.keybd_event(13, 0, win32con.KEYEVENTF_KEYUP, 0)
167            time.sleep(1)
168            dialog1 = win32gui.FindWindow('ThunderRT6FormDC', '911 S5 3.1')
169            login = win32gui.FindWindowEx(
170                dialog1, 0, 'ThunderRT6CommandButton', None)
171            win32gui.SendMessage(dialog1, win32con.WM_COMMAND, 0, login)
172            time.sleep(5)
173            try_time += 1
174            if try_time > 5:
175                break
176        while True:
177            p = subprocess.Popen('C:\\Users\\Administrator\\Desktop\\911S5 2018-05-23 fixed\\ProxyTool\\Autoproxytool.exe -changeproxy/all/%s/%s -citynolimit' % (state, city),
178                                 shell=False, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
179            p.wait()
180            time.sleep(5)
181            options = webdriver.ChromeOptions()
182            options.add_argument('disable-infobars')
183            driver = webdriver.Chrome(chrome_options=options)
184            driver.maximize_window()
185            driver.get('https://www.paypal.com/us/signin')
186            time.sleep(3)
187            if driver.page_source.find('This site can’t be reached') > -1:
188                print('Net error!')
189                driver.quit()
190                time.sleep(1)
191                continue
192            else:
193                break
194        login_flag = click_login(driver, conn, email, password, pp_nickname)
195        if driver.page_source.find('Confirm your phone for extra security') > -1:
196            upgrade_flag = 1
197            login_flag = 1
198            sql = 'UPDATE paypal_info set login_state=1 where paypal_id=%s'
199            commit_sql(conn, sql, pp_nickname)
200            time.sleep(0.5)
201        if step_flag == 2 and login_flag == 1:
202            search_upgrade = 0
203            while True:
204                upgrade_element = ''
205                try:
206                    upgrade_element = driver.find_element_by_xpath(
207                        '//a[@data-name="confirm_your_mobile"]')
208                except:
209                    pass
210                if upgrade_element:
211                    upgrade_flag = 1
212                    break
213                else:
214                    time.sleep(2)
215                    search_upgrade += 1
216                if search_upgrade > 3:
217                    break
218            if upgrade_flag == 1:
219                upgrade_account(driver, name, phonenum, address, city, full_state, zip_num, ssn, birthdate)
220            try:
221                info_num = driver.find_element_by_xpath(
222                    '//div[@data-testid="AlertBellIcon"]//span').text
223                # print(info_num)
224                if int(info_num) > 3:
225                    # paypal_error(driver)
226                    PAYPAL_INFO['paypal']['paypal_state'] = '4'
227                    withdraw_flag = 0
228                else:
229                    PAYPAL_INFO['paypal']['paypal_state'] = '1'
230                    # driver.find_element_by_xpath('//div[@data-testid="AlertBellIcon"]').click()
231            except:
232                pass
233            try:
234                order_state_element = driver.find_elements_by_xpath(
235                    '//div[@class="table-responsive"]/table//tr//td[2]/a')
236                if not order_state_element:
237                    driver.refresh()
238                    time.sleep(5)
239                    order_state_element = driver.find_elements_by_xpath(
240                        '//div[@class="table-responsive"]/table//tr//td[2]/a')
241                if order_state_element:
242                    if not PAYPAL_INFO['paypal']['paypal_state']:
243                        PAYPAL_INFO['paypal']['paypal_state'] = '1'
244                for order in order_state_element:
245                    order_num = order.get_attribute('href')
246                    order_num = order_num.replace('https://www.paypal.com', '')
247                    print(order_num)
248                    q.put(order_num)
249            except:
250                pass
251            while q.qsize() > 0:
252                custom = ''
253                order_flag = q.get()
254                print(order_flag)
255                while True:
256                    order_state = ''
257                    search_state_times = 0
258                    while True:
259                        try:
260                            order_state = driver.find_element_by_xpath(
261                                '//div[@class="table-responsive"]/table//tr//td[2]/a[@href="%s"]//li' % order_flag).text
262                            # print(order_state)
263                        except Exception as e:
264                            pass
265                        if not order_state:
266                            time.sleep(3)
267                            try:
268                                all_order_state = driver.find_elements_by_xpath(
269                                    '//div[@class="table-responsive"]/table//tr//td[2]/a//li')
270                                order_state = all_order_state[0].text
271                            except:
272                                pass
273                            if not order_state:
274                                try:
275                                    order_state = driver.find_element_by_xpath(
276                                        '//div[@class="table-responsive"]/table//tr//td[2]/a[@href="%s"]//li/span' % order_flag).text
277                                except:
278                                    pass
279                        if order_state:
280                            print(order_state)
281                            break
282                        else:
283                            time.sleep(2)
284                            search_state_times += 1
285                        if search_state_times > 3:
286                            break
287                    # Denied 取款失败
288                    if order_state == 'Completed':
289                        if custom:
290                            if PAYPAL_INFO['paypal']['paypal_state'] == '1':
291                                PAYPAL_INFO['order'][custom] = '1'
292                            elif PAYPAL_INFO['paypal']['paypal_state'] == '4':
293                                PAYPAL_INFO['order'][custom] = '2'
294                        else:
295                            order_type = driver.find_element_by_xpath(
296                                '//div[@class="table-responsive"]/table//tr//td[2]/a[@href="%s"]/b' % order_flag).text
297                            if order_type in STATE_LIST:
298                                break
299                            else:
300                                try:
301                                    driver.find_element_by_xpath(
302                                        '//div[@class="table-responsive"]/table//tr//td[2]/a[@href="%s"]' % order_flag).click()
303                                    time.sleep(3)
304                                except:
305                                    pass
306                                try:
307                                    custom = driver.find_element_by_xpath(
308                                        '//section[@class="Notes pagebreak"]//p').text
309                                    print(custom)
310                                    driver.find_element_by_xpath(
311                                        '//a[text()="Summary"]').click()
312                                    time.sleep(5)
313                                except:
314                                    pass
315                                if PAYPAL_INFO['paypal']['paypal_state'] == '1':
316                                    PAYPAL_INFO['order'][custom] = '1'
317                                elif PAYPAL_INFO['paypal']['paypal_state'] == '4':
318                                    PAYPAL_INFO['order'][custom] = '2'
319                        break
320                    elif order_state == 'ON HOLD' or order_state == 'Held' or order_state == 'On Hold':
321                        if custom:
322                            if PAYPAL_INFO['paypal']['paypal_state'] == '1':
323                                PAYPAL_INFO['order'][custom] = '3'
324                            elif PAYPAL_INFO['paypal']['paypal_state'] == '4':
325                                PAYPAL_INFO['order'][custom] = '4'
326                        else:
327                            try:
328                                driver.find_element_by_xpath(
329                                    '//div[@class="table-responsive"]/table//tr//td[2]/a[@href="%s"]' % order_flag).click()
330                                time.sleep(3)
331                            except:
332                                pass
333                            try:
334                                custom = driver.find_element_by_xpath(
335                                    '//section[@class="Notes pagebreak"]//p').text
336                                print(custom)
337                                driver.find_element_by_xpath(
338                                    '//a[text()="Summary"]').click()
339                                time.sleep(5)
340                            except:
341                                pass
342                            if PAYPAL_INFO['paypal']['paypal_state'] == '1':
343                                PAYPAL_INFO['order'][custom] = '3'
344                            elif PAYPAL_INFO['paypal']['paypal_state'] == '4':
345                                PAYPAL_INFO['order'][custom] = '4'
346                        break
347                    elif order_state == 'Pending':
348                        # print('Pending!')
349                        order_msg = submit_order(driver, order_flag)
350                        if order_msg:
351                            custom = order_msg['custom']
352                            print(custom)
353                            if order_msg['success_flag'] == '4':
354                                if PAYPAL_INFO['paypal']['paypal_state'] == '1':
355                                    PAYPAL_INFO['order'][custom] = '3'
356                                elif PAYPAL_INFO['paypal']['paypal_state'] == '4':
357                                    PAYPAL_INFO['order'][custom] = '4'
358                                break
359                    elif order_state == 'Unclaimed':
360                        exchange_remittance(driver, order_flag)
361                        # print('Unclaimed!')
362                    else:
363                        print('Unknow Error!')
364                        break
365            try:
366                get_balance(driver, conn, pp_nickname, email)
367                PAYPAL_INFO['order'] = json.loads(PAYPAL_INFO['order'])
368                PAYPAL_INFO['paypal'] = json.loads(PAYPAL_INFO['paypal'])
369                withdraw_money = int(PAYPAL_INFO['paypal']['usable_money'].split('.')[0])
370                print('withdraw: ', withdraw_money)
371                if withdraw_flag == 1 and withdraw_money > 10 and withdraw_state == 1:
372                    withdraw(driver, conn, pp_nickname, email)
373                sql = 'UPDATE paypal_info set is_end=0 where paypal_id=%s'
374                commit_sql(conn, sql, pp_nickname)
375            except:
376                pass
377