def get_forks_info(origin: Repository, client: Client) -> List[ForkInfo]: """ Requests forks and wraps them in 'ForkInfo' objects """ result = [] forks = origin.get_forks() log.info('got list of forks, total %d', forks.totalCount) client.count_rate_limit(1) try: rate_limits_check(client, forks.totalCount + pagination_correction(forks.totalCount, 30)) except RateLimitError: return for fork in forks: try: log.info('comparing fork: %s', fork.full_name) comparison = origin.compare(origin.owner.login + ":master", fork.owner.login + ":master") fi = ForkInfo(fork.html_url, (abs(datetime.now() - fork.updated_at)).days, fork.stargazers_count, comparison.ahead_by, comparison.behind_by) result.append(fi) except UnknownObjectException as e: log.exception('possibly removed fork or user: %s, %d, message: %s', fork.html_url, e.status, e.data.get('message', '')) except GithubException as e: message = e.data.get('message', '') if e.status == 404 and 'No common ancestor between ' in message: # that can be handled log.error('404 %s', message) handle_github_exception(result, fork) else: log.exception('github error') client.count_rate_limit(forks.totalCount + pagination_correction(forks.totalCount, 30)) return result
def start_proc(self): cnt = 0 for guest in self.unit_case.guests: client = Client() client.ai_action = self.unit_case.build_ai(client) client.guest_info = guest cnt += 1 if cnt < 30: time.sleep(10) else: time.sleep(1)
def postHost(request): ip = request.POST.get('ip', '') uname = request.POST.get('username', '') pwd = request.POST.get('password', '') Client(ip=ip, uname=uname, pwd=pwd) session = Session(ip=ip) session.setHost() return HttpResponse(json.dumps({"info": "success"}))
def add_bot(self, target, sshuser, passwd): client = Client(target, sshuser, passwd) if client.session != False: self.BotNet.append(client) dt = time.ctime() self.log.log_append('\n[+] Successful connection with ' + client.target + '\n-> OS Specs: ' + self.ver.LinVer(client) + '\n-> Date and time: ' + dt)
class Application(object): app_thread = None start_thread = None is_running = False unit_case = None def run_case(self, case): if len(case.guests) <= 0: return self.unit_case = case for guest in case.guests: client = Client() client.ai_action = case.build_ai(client) client.guest_info = guest
def get_github_client(args: Namespace) -> Client: api_key = args.token or os.getenv(args.token_var, default=None) return Client(api_key)
#!/usr/bin/env python #-*- coding:utf-8 -*- __author__ = 'jfsu' import sys import os BASE_DIR = os.path.dirname( os.path.dirname( os.path.abspath(__file__) ) ) sys.path.append(BASE_DIR) from core import Client if __name__ == '__main__': fc = Client.ftpClient()