def save(self, command, info): global filename with open(filename.replace('link', 'sql_info'), 'ab') as f, open(filename.replace('link', 'sql_crash'), 'ab') as f1: file_lock = lockfile.MkdirFileLock( filename.replace('link', 'sql_info')) while (1): try: file_lock.acquire() except: time.sleep(0.1) else: break f.write( bytes((r'D:\>' + command).replace('\n', ''), encoding='utf-8')) f.write(bytes(info, encoding='utf-8')) file_lock.release() file_lock = lockfile.MkdirFileLock( filename.replace('link', 'sql_crash')) while (1): try: file_lock.acquire() except: time.sleep(0.1) else: break f1.write(bytes(command + '\r\n', encoding='utf-8')) file_lock.release()
def file_lock(self,filename,content): with open(filename,'a+',encoding='utf-8') as f1: file_lock = lockfile.MkdirFileLock(filename) while(1): try: file_lock.acquire() except: time.sleep(0.1) else: break f1.write(content) file_lock.release()
def lock_file(self,filename,text): with open(filename,'a',encoding='utf-8')as f: file_lock = lockfile.MkdirFileLock(filename) while(1): try: file_lock.acquire() except: time.sleep(0.1) else: break f.write(text) file_lock.release()
def enable_container_cdn(self, container): """ Enable container CDN. :param container: Container instance :type container: :class:`Container` :rtype: ``bool`` """ path = self.get_container_cdn_url(container) lockfile.MkdirFileLock(path, threaded=True) with LockLocalStorage(path): self._make_path(path) return True
def run(self): global filename while not self._queue.empty(): url = self._queue.get() if 'tcpwrapped' in url: time_out = 3 url = url.replace('tcpwrapped', '') else: time_out = 15 url_list = [url] headers = { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.67 Safari/537.36' } try: r = requests.get( url, verify=False, timeout=time_out, headers=headers ) #, proxies={'http':'http://42.51.42.201:808'}) except: if 'https' not in url: try: r = requests.get(url.replace('http', 'https'), verify=False, timeout=time_out, headers=headers) except: continue else: continue ## else: ## if r.status_code//100 > 4: ## continue url_list = self.url_redirects(r, url_list) ## if url_list: try: html = r.content ## if not html: ## continue url_list.append(Document(html).title()) #url_list.append(Document(requests.get(requests.get(url, verify=False, headers = headers).url, verify=False, timeout=10, headers = headers).text).title()) #url_list.append(BeautifulSoup(requests.get(url, verify=False, timeout=10, headers = headers).text.encode('iso-8859-1').decode('utf-8'), 'lxml').title.string) except: pass print(url_list) with open(filename.replace('nmap', 'port_link'), 'a', encoding='utf-8') as f: file_lock = lockfile.MkdirFileLock( filename.replace('nmap', 'port_link')) while (1): try: file_lock.acquire() except: time.sleep(0.1) else: break f.write(str(url_list) + ' [' + str(r.status_code) + ']\n') file_lock.release()