Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GUI and Improved Documentation #32

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,37 @@
* (optional) Change server ip/port number in config.
* All other packages that generate error "No module named" does exist, must be installed.

## Installation and Setup

Clone the repository and move into the directory

```
git clone https://github.com/oduwsdl/CarbonDate
cd CarbonDate
```

Install python requirements

```
pip install -r requirements.txt
```

### Missing Aysnchronous attribute

![Example Error](https://github.com/njenn001/CarbonDate/blob/master/images/Error.jpg)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make the image source relative, so it does not point to a specific fork.

Suggested change
![Example Error](https://github.com/njenn001/CarbonDate/blob/master/images/Error.jpg)
![Example Error](images/Error.jpg)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm kind of curious where this error stems from. I don't have issues with the docker hub image.

Maybe there is a Python version and library version mismatch going on? The docker image is python 3.7 with the following library versions:

$ docker run -it --rm oduwsdl/carbondate bash
root@4d968fac6b3c:/usr/src/app# pip3 list --format freeze
atomicwrites==1.1.5
attrs==18.1.0
beautifulsoup4==4.6.3
certifi==2018.8.13
chardet==3.0.4
idna==2.7
lxml==4.2.4
more-itertools==4.3.0
pip==18.0
pluggy==0.7.1
py==1.5.4
pytest==3.7.1
python-dateutil==2.7.3
requests==2.19.1
requests-file==1.4.3
setuptools==40.0.0
six==1.11.0
surt==0.3.0
tldextract==2.2.0
tornado==5.1
urllib3==1.23
wheel==0.31.1


For quick installation and running purposes simply comment out the use of the server import in main.py. Otherwise, check Tornado import.

![Example Solution](https://github.com/njenn001/CarbonDate/blob/master/images/solution.JPG)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make the image source relative, so it does not point to a specific fork.

Suggested change
![Example Solution](https://github.com/njenn001/CarbonDate/blob/master/images/solution.JPG)
![Example Solution](images/solution.JPG)


### Missing/Broken Modules
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these modules broken? Open separate issues with details to either fix or remove them.


* Twitter
* Bitly
* Bing



## Running as a Docker Container

It is recommended to use [Docker](https://www.docker.com/) to install and run this application.
Expand Down Expand Up @@ -55,6 +86,19 @@ To run it in one-off mode:
$ ./main.py -l {URI-R}
```

### Running the GUI


* Initialized in terminal
```
$ ./main.py --gui
```
* Use the small tkinter window to carbon date URLs

* ![GUI Figure](https://github.com/njenn001/CarbonDate/blob/master/images/GuiFig.png)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make the image source relative, so it does not point to a specific fork.

Suggested change
* ![GUI Figure](https://github.com/njenn001/CarbonDate/blob/master/images/GuiFig.png)
* ![GUI Figure](images/GuiFig.png)


* Output will lie in the terminal

### Environment variables

Carbon Date provides the option of passing in environment variables for both the Bing and Bitly services.
Expand Down
2 changes: 1 addition & 1 deletion config
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"AccessToken":["YourBitlyAccessTokenHere"],
"AccessToken":["Yf7d318a38ee40a5049861a32814bb1b0fb78cb8b"],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to provide an access token in the source? This token will perhaps be revoked by GitHub. It is better to tell user how to create a token and then they can use that instead.

"BingAPIKey":"YourBingSearchAPIKey",
"ServerIP": "0.0.0.0",
"ServerPort": 8888,
Expand Down
2 changes: 1 addition & 1 deletion core.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def run(self, args, **kwargs):
if args.local_uri:
url = args.local_uri
else:
url = kwargs['url']
url = 'https://www.cs.odu.edu/'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the reason of this change?

# handle character accents
url = requote_uri(url)

Expand Down
1,201 changes: 1,201 additions & 0 deletions dataset.txt

Large diffs are not rendered by default.

75 changes: 75 additions & 0 deletions gui.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import tkinter as tk

LARGE_FONT= ("Verdana", 12)


class Gui(tk.Tk):

def __init__(self, *args, **kwargs):

tk.Tk.__init__(self, *args, **kwargs)
container = tk.Frame(self)

container.pack(side="top",expand = True)

container.grid_rowconfigure(0, weight=1)
container.grid_columnconfigure(0, weight=1)

self.frames = {}

for F in ([StartPage]):

frame = F(container, self)

self.frames[F] = frame

frame.grid(row=0, column=0, sticky="nsew")

self.show_frame(StartPage)

def show_frame(self, cont):

frame = self.frames[cont]
frame.tkraise()


#FORMATTING FUNCTION FOR THE TKINTER ENTRY BOX


class StartPage(tk.Frame):

def __init__(self, parent, controller):
def on_entry_click(event):
"""function that gets called whenever entry is clicked"""
if URIentry.get() == 'https://cs.odu.edu/':
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding hardcoded values like this is not a good practice. If this were to be used as the sample URI, a constant should be defined at the top of the file or better yet, add this in the config file to reuse everywhere.

URIentry.delete(0, "end") # delete all the text in the entry
URIentry.insert(0, '') #Insert blank for user input
URIentry.config(fg = 'black')
def on_focusout(event):
if URIentry.get() == '':
URIentry.insert(0, 'https://cs.odu.edu/')
URIentry.config(fg = 'grey')
def startlocal(uri):
print (uri)

tk.Frame.__init__(self,parent)

label = tk.Label(self, text="CarbonDate", font=LARGE_FONT)
label.pack(pady=20,padx=50)

label = tk.Label(self, text="Enter Uri:")
label.pack()
URIentry = tk.Entry(self)
URIentry.insert(0, 'https://cs.odu.edu/')
URIentry.config(fg = 'grey')
URIentry.bind('<FocusIn>', on_entry_click)
URIentry.bind('<FocusOut>', on_focusout)
URIentry.pack()

button = tk.Button(self, text="Estimate birthdate",
command=lambda: controller.show_frame(startlocal(URIentry.get())))
button.pack()




Binary file added images/Error.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/GuiFig.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/solution.JPG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
44 changes: 44 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
import server
import local
import core
import gui
import json
import time
import tkinter as tk
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to update requirements.txt to include tkinter and gui.


logo = ('''
_____ ___ _____ _____ _____ __ _ _____ ___ _____ _____
Expand All @@ -23,7 +25,10 @@ def parserinit():
formatter_class=argparse.RawDescriptionHelpFormatter,
description=logo + 'Integrated interface for Carbon Date Tool',
epilog='For more help, type main.py -h')

mode_group = parser.add_mutually_exclusive_group(required=True)
mode_group.add_argument('--gui', help='Activate the tkinter implementation.',
action='store_true')
mode_group.add_argument('--list-mods', action='store_true',
help='List all avaiable modules')
mode_group.add_argument('-s', '--server', action='store_true',
Expand All @@ -32,11 +37,13 @@ def parserinit():
help='Run Carbon Date Tool as a local application.'
' Takes a URI as a parameter',
dest="local_uri")

parser.add_argument('-t', '--timeout', type=int,
help='Set timeout for all modules in seconds',
default=300)
parser.add_argument(
'-v', '--verbose', action='store_true', help='Enable verbose output')

modOpGroup = parser.add_mutually_exclusive_group()
modOpGroup.add_argument('-a', '--all', action="store_true",
help='Load all modules (default)', dest='all')
Expand All @@ -47,6 +54,23 @@ def parserinit():
'-e', metavar='MODULE', help="Exclusive mode, load all modules except \
the given modules", nargs='+')
return parser

#FORMATTING FUNCTION FOR THE TKINTER ENTRY BOX
def on_entry_click(event):
"""function that gets called whenever entry is clicked"""
if nameE.get() == 'https://www.cs.odu.edu':
nameE.delete(0, "end") # delete all the text in the entry
nameE.insert(0, '') #Insert blank for user input
nameE.config(fg = 'black')
def on_focusout(event):
if nameE.get() == '':
nameE.insert(0, 'https://www.cs.odu.edu')
nameE.config(fg = 'grey')

def passArgs(args, mod, name):
args.local_uri = name

local.start(args, mod)


if __name__ == '__main__':
Expand All @@ -68,6 +92,7 @@ def parserinit():
mod = core.ModuleManager()
mod.loadModule(cfg, args)


if args.list_mods:
print('Available Modules (include system utilities)')
print('====================================')
Expand All @@ -78,3 +103,22 @@ def parserinit():
server.start(args, cfg, mod)
elif args.local_uri:
local.start(args, mod)
elif args.gui:
root = tk.Tk()
root.title('CarbonDate')
nameL = tk.Label (root, text="URL")
nameL.grid(column = 0, row = 0, sticky = "W")

nameE = tk.Entry(root, bd = 5, width = 25)
nameE.insert(0, 'https://www.cs.odu.edu/')
nameE.config(fg = 'grey')
nameE.bind('<FocusIn>', on_entry_click)
nameE.bind('<FocusOut>', on_focusout)
nameE.grid(column = 1, row = 0, sticky = "W")
s = tk.Button(root, text="Start", command = lambda : passArgs(args, mod, str(nameE.get())))
s.grid(column = 2, row = 0, pady = 5)
root.mainloop()


# gui = gui.Gui()
# gui.mainloop()