Skip to content

Commit

Permalink
code fix
Browse files Browse the repository at this point in the history
  • Loading branch information
xzyaoi committed Nov 13, 2018
1 parent d7f45a4 commit 6d5d1fb
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 21 deletions.
5 changes: 3 additions & 2 deletions README.md
Expand Up @@ -11,8 +11,9 @@
[![Maintainability](https://api.codeclimate.com/v1/badges/d66183d5e7ed7d8f0ca2/maintainability)](https://codeclimate.com/github/unarxiv/CVPM/maintainability)
[![BCH compliance](https://bettercodehub.com/edge/badge/unarxiv/CVPM?branch=master)](https://bettercodehub.com/)
[![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/2343/badge)](https://bestpractices.coreinfrastructure.org/projects/2343)

![logo-with-slogan-landscape.png](https://i.loli.net/2018/10/20/5bcb455c17616.png)
[![Total alerts](https://img.shields.io/lgtm/alerts/g/unarxiv/CVPM.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/unarxiv/CVPM/alerts/)
[![Language grade: JavaScript](https://img.shields.io/lgtm/grade/javascript/g/unarxiv/CVPM.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/unarxiv/CVPM/context:javascript)
[![Language grade: Python](https://img.shields.io/lgtm/grade/python/g/unarxiv/CVPM.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/unarxiv/CVPM/context:python)

## Introduction

Expand Down
2 changes: 2 additions & 0 deletions cvpm/bundle.py
Expand Up @@ -5,6 +5,8 @@ def is_jsonable(x):
try:
json.dumps(x)
return True
except Exception as ex:
print(ex)
except:
return False

Expand Down
5 changes: 2 additions & 3 deletions cvpm/server.py
Expand Up @@ -4,7 +4,7 @@
import socket
import traceback
import gevent.pywsgi
from flask import Flask, g, request
from flask import Flask, request
from werkzeug.datastructures import ImmutableMultiDict
from werkzeug.utils import secure_filename

Expand All @@ -24,12 +24,11 @@ def str2bool(v):
def _isPortOpen(port):
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
result = s.connect_ex(('127.0.0.1', port))
s.close()
if result == 0:
return True
else:
return False
s.close()


def get_available_port(start=8080):
port = start
Expand Down
4 changes: 1 addition & 3 deletions cvpm/solver.py
@@ -1,12 +1,10 @@
import json

import requests
import toml
import tqdm

from cvpm.bundle import Bundle
from cvpm.server import run_server
from cvpm.utility import BundleAnalyzer, Downloader
from cvpm.utility import Downloader


class Solver(object):
Expand Down
13 changes: 0 additions & 13 deletions cvpm/utility.py
Expand Up @@ -25,7 +25,6 @@ def download(self, url, target):
filename = url.split('/')[-1]
file_size = int(urlopen(url).info().get('Content-Length', -1))
chunk_size = 1024
bars = int(file_size / chunk_size)
dest = os.path.join(target, filename)
if os.path.exists(dest):
first_byte = os.path.getsize(dest)
Expand All @@ -48,15 +47,3 @@ def download(self, url, target):
pbar.update(1024)
pbar.close()
return file_size


class BundleAnalyzer(object):
def __init__(self, bundle):
self.bundle = bundle

def load(self):
result = {}
for name, value in vars(self.bundle).items():
if not name.startsWith("__"):
result[name] = value
return result

0 comments on commit 6d5d1fb

Please sign in to comment.