def testajax(self):
        """测试ajax方法"""
        xmlstr = (
            "<root>"
            '<house id="1" regid="1" serid="7"/>'
            '<house id="4" regid="3" serid="1"/>'
            '<house id="5" regid="2" serid="1"/>'
            '<house id="6" regid="1" serid="4"/>'
            '<house id="2" regid="1" serid="5"/>'
            "</root>"
        )

        ajax.ajax(xmlstr)
        self.assertEqual(1, 1)
def urlopen(url, data=None, timeout=None):
    global result
    result=None

    def on_complete(req):
        global result
        result=req

    _ajax=ajax.ajax()
    _ajax.bind('complete', on_complete)
    if timeout is not None:
       _ajax.set_timeout(timeout)

    _ajax.open('GET', url, False)
    if data is None:
       _ajax.send()
    else:
       _ajax.send(data)

    return FileIO(result.text), url, result.headers
Exemple #3
0
		print u"Error adding skill to the database:\n%s" % result[u"error"]
		print u"Original JSON request sent was:\n%s" % demjson.encode(action)
		sys.exit()
	else:
		print u"Skill '%s' added to the database at row %d (%d of %d)" \
			% ( name, result[u"ids"][0], done, total )

# ---------
# Main Code
# ---------

random.seed()
if not os.path.exists("cache"):
	os.mkdir("cache")

ajax_inst = ajax.ajax()
ajax_inst.login()

print u""
print u"Finding the skill list..."

url = "http://artifact.sakura.ne.jp/imagine/"

keys = ["chkbox12", "chkbox2", "chkbox31", "chkbox32", "chkbox33",
	"chkbox34", "chkbox35", "chkbox36", "chkbox37", "chkbox38", "chkbox39",
	"data1_1_old", "data1_2_old", "data1_3_old", "data1_4_old", "data2_1",
	"data2_1_old", "data2_2_old", "data2_3_old", "data2_4_old", "data3_1_old",
	"data3_2_old", "data3_3_old", "data3_4_old", "data4_1_old", "data4_2_old",
	"data4_3_old", "data4_4_old", "data5_1_old", "data5_2_old", "data5_3_old",
	"data5_4_old", "data6_1_old", "data6_2_old", "data6_3_old", "data6_4_old",
	"data7_1_old", "data7_2_old", "data7_3_old", "data7_4_old", "data7_5_old",
Exemple #4
0
 def funObj(self):
     import ajax
     ajaxObject = ajax.ajax()
     defs = ('GetFpmLogs','GetFpmSlowLogs','SetMemcachedCache','GetMemcachedStatus','GetRedisStatus','GetWarning','SetWarning','CheckLogin','GetSpeed','GetAd','phpSort','ToPunycode','GetBetaStatus','SetBeta','setPHPMyAdmin','delClose','KillProcess','GetPHPInfo','GetQiniuFileList','UninstallLib','InstallLib','SetQiniuAS','GetQiniuAS','GetLibList','GetProcessList','GetNetWorkList','GetNginxStatus','GetPHPStatus','GetTaskCount','GetSoftList','GetNetWorkIo','GetDiskIo','GetCpuIo','CheckInstalled','UpdatePanel','GetInstalled','GetPHPConfig','SetPHPConfig')
     return publicObject(ajaxObject,defs);
Exemple #5
0
    def ServiceAdmin(self, get=None):
        #服务管理
        if get.name == 'mysqld':
            public.CheckMyCnf()
            self.__check_mysql_path()
        if get.name.find('webserver') != -1:
            get.name = public.get_webserver()

        if get.name == 'phpmyadmin':
            import ajax
            get.status = 'True'
            ajax.ajax().setPHPMyAdmin(get)
            return public.returnMsg(True, 'SYS_EXEC_SUCCESS')

        if get.name == 'openlitespeed':
            if get.type == 'stop':
                public.ExecShell(
                    'rm -f /tmp/lshttpd/*.sock* && /usr/local/lsws/bin/lswsctrl stop'
                )
            elif get.type == 'start':
                public.ExecShell(
                    'rm -f /tmp/lshttpd/*.sock* && /usr/local/lsws/bin/lswsctrl start'
                )
            else:
                public.ExecShell(
                    'rm -f /tmp/lshttpd/*.sock* && /usr/local/lsws/bin/lswsctrl restart'
                )
            return public.returnMsg(True, 'SYS_EXEC_SUCCESS')

        #检查httpd配置文件
        if get.name == 'apache' or get.name == 'httpd':
            get.name = 'httpd'
            if not os.path.exists(self.setupPath + '/apache/bin/apachectl'):
                return public.returnMsg(True, 'SYS_NOT_INSTALL_APACHE')
            vhostPath = self.setupPath + '/panel/vhost/apache'
            if not os.path.exists(vhostPath):
                public.ExecShell('mkdir ' + vhostPath)
                public.ExecShell('/etc/init.d/httpd start')

            if get.type == 'start':
                public.ExecShell('/etc/init.d/httpd stop')
                self.kill_port()

            result = public.ExecShell('ulimit -n 8192 ; ' + self.setupPath +
                                      '/apache/bin/apachectl -t')
            if result[1].find('Syntax OK') == -1:
                public.WriteLog("TYPE_SOFT", 'SYS_EXEC_ERR', (str(result), ))
                return public.returnMsg(False, 'SYS_CONF_APACHE_ERR',
                                        (result[1].replace("\n", '<br>'), ))

            if get.type == 'restart':
                public.ExecShell('pkill -9 httpd')
                public.ExecShell('/etc/init.d/httpd start')
                time.sleep(0.5)

        #检查nginx配置文件
        elif get.name == 'nginx':
            vhostPath = self.setupPath + '/panel/vhost/rewrite'
            if not os.path.exists(vhostPath):
                public.ExecShell('mkdir ' + vhostPath)
            vhostPath = self.setupPath + '/panel/vhost/nginx'
            if not os.path.exists(vhostPath):
                public.ExecShell('mkdir ' + vhostPath)
                public.ExecShell('/etc/init.d/nginx start')

            result = public.ExecShell('ulimit -n 8192 ; nginx -t -c ' +
                                      self.setupPath +
                                      '/nginx/conf/nginx.conf')
            if result[1].find('perserver') != -1:
                limit = self.setupPath + '/nginx/conf/nginx.conf'
                nginxConf = public.readFile(limit)
                limitConf = "limit_conn_zone $binary_remote_addr zone=perip:10m;\n\t\tlimit_conn_zone $server_name zone=perserver:10m;"
                nginxConf = nginxConf.replace(
                    "#limit_conn_zone $binary_remote_addr zone=perip:10m;",
                    limitConf)
                public.writeFile(limit, nginxConf)
                public.ExecShell('/etc/init.d/nginx start')
                return public.returnMsg(True, 'SYS_CONF_NGINX_REP')

            if result[1].find('proxy') != -1:
                import panelSite
                panelSite.panelSite().CheckProxy(get)
                public.ExecShell('/etc/init.d/nginx start')
                return public.returnMsg(True, 'SYS_CONF_NGINX_REP')

            #return result
            if result[1].find('successful') == -1:
                public.WriteLog("TYPE_SOFT", 'SYS_EXEC_ERR', (str(result), ))
                return public.returnMsg(False, 'SYS_CONF_NGINX_ERR',
                                        (result[1].replace("\n", '<br>'), ))

            if get.type == 'start':
                self.kill_port()
                time.sleep(0.5)
        if get.name == 'redis':
            redis_init = '/etc/init.d/redis'
            if os.path.exists(redis_init):
                init_body = public.ReadFile(redis_init)
                if init_body.find('pkill -9 redis') == -1:
                    public.ExecShell("wget -O " + redis_init + " " +
                                     public.get_url() + '/init/redis.init')
                    public.ExecShell("chmod +x " + redis_init)

        #执行
        execStr = "/etc/init.d/" + get.name + " " + get.type
        if execStr == '/etc/init.d/pure-ftpd reload':
            execStr = self.setupPath + '/pure-ftpd/bin/pure-pw mkdb ' + self.setupPath + '/pure-ftpd/etc/pureftpd.pdb'
        if execStr == '/etc/init.d/pure-ftpd start':
            public.ExecShell('pkill -9 pure-ftpd')
        if execStr == '/etc/init.d/tomcat reload':
            execStr = '/etc/init.d/tomcat stop && /etc/init.d/tomcat start'
        if execStr == '/etc/init.d/tomcat restart':
            execStr = '/etc/init.d/tomcat stop && /etc/init.d/tomcat start'

        if get.name != 'mysqld':
            result = public.ExecShell(execStr)
        else:
            public.ExecShell(execStr)
            result = []
            result.append('')
            result.append('')

        if result[1].find('nginx.pid') != -1:
            public.ExecShell('pkill -9 nginx && sleep 1')
            public.ExecShell('/etc/init.d/nginx start')
        if get.type != 'test':
            public.WriteLog("TYPE_SOFT", 'SYS_EXEC_SUCCESS', (execStr, ))

        if len(result[1]
               ) > 1 and get.name != 'pure-ftpd' and get.name != 'redis':
            return public.returnMsg(
                False,
                '<p>Warning message: <p>' + result[1].replace('\n', '<br>'))
        return public.returnMsg(True, 'SYS_EXEC_SUCCESS')