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

Basic Support for Python 3 #827

Merged
merged 8 commits into from
Jan 23, 2017
Merged
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
*.pyc
/netbox/netbox/configuration.py
/netbox/netbox/ldap_config.py
/netbox/static
.idea
/*.sh
Expand Down
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ env:
language: python
python:
- "2.7"
- "3.4"
- "3.5"
- "3.6"
install:
- pip install -r requirements.txt
- pip install pep8
Expand Down
4 changes: 2 additions & 2 deletions docs/installation/netbox.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
**Debian/Ubuntu**

```no-highlight
# apt-get install -y python2.7 python-dev python-pip libxml2-dev libxslt1-dev libffi-dev graphviz libpq-dev libssl-dev
# apt-get install -y python3 python3-dev python3-pip libxml2-dev libxslt1-dev libffi-dev graphviz libpq-dev libssl-dev
```

**CentOS/RHEL**

```no-highlight
# yum install -y epel-release
# yum install -y gcc python2 python-devel python-pip libxml2-devel libxslt-devel libffi-devel graphviz openssl-devel
# yum install -y gcc python3 python3-devel python3-pip libxml2-devel libxslt-devel libffi-devel graphviz openssl-devel
```

You may opt to install NetBox either from a numbered release or by cloning the master branch of its repository on GitHub.
Expand Down
13 changes: 9 additions & 4 deletions netbox/circuits/models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from django.contrib.contenttypes.fields import GenericRelation
from django.core.urlresolvers import reverse
from django.db import models
from django.utils.encoding import python_2_unicode_compatible

from dcim.fields import ASNField
from extras.models import CustomFieldModel, CustomFieldValue
Expand Down Expand Up @@ -33,6 +34,7 @@ def humanize_speed(speed):
return '{} Kbps'.format(speed)


@python_2_unicode_compatible
class Provider(CreatedUpdatedModel, CustomFieldModel):
"""
Each Circuit belongs to a Provider. This is usually a telecommunications company or similar organization. This model
Expand All @@ -51,7 +53,7 @@ class Provider(CreatedUpdatedModel, CustomFieldModel):
class Meta:
ordering = ['name']

def __unicode__(self):
def __str__(self):
return self.name

def get_absolute_url(self):
Expand All @@ -67,6 +69,7 @@ def to_csv(self):
])


@python_2_unicode_compatible
class CircuitType(models.Model):
"""
Circuits can be organized by their functional role. For example, a user might wish to define CircuitTypes named
Expand All @@ -78,13 +81,14 @@ class CircuitType(models.Model):
class Meta:
ordering = ['name']

def __unicode__(self):
def __str__(self):
return self.name

def get_absolute_url(self):
return "{}?type={}".format(reverse('circuits:circuit_list'), self.slug)


@python_2_unicode_compatible
class Circuit(CreatedUpdatedModel, CustomFieldModel):
"""
A communications circuit connects two points. Each Circuit belongs to a Provider; Providers may have multiple
Expand All @@ -105,7 +109,7 @@ class Meta:
ordering = ['provider', 'cid']
unique_together = ['provider', 'cid']

def __unicode__(self):
def __str__(self):
return u'{} {}'.format(self.provider, self.cid)

def get_absolute_url(self):
Expand Down Expand Up @@ -141,6 +145,7 @@ def commit_rate_human(self):
commit_rate_human.admin_order_field = 'commit_rate'


@python_2_unicode_compatible
class CircuitTermination(models.Model):
circuit = models.ForeignKey('Circuit', related_name='terminations', on_delete=models.CASCADE)
term_side = models.CharField(max_length=1, choices=TERM_SIDE_CHOICES, verbose_name='Termination')
Expand All @@ -156,7 +161,7 @@ class Meta:
ordering = ['circuit', 'term_side']
unique_together = ['circuit', 'term_side']

def __unicode__(self):
def __str__(self):
return u'{} (Side {})'.format(self.circuit, self.get_term_side_display())

def get_peer_termination(self):
Expand Down
2 changes: 1 addition & 1 deletion netbox/dcim/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
SlugField,
)

from formfields import MACAddressFormField
from .formfields import MACAddressFormField
from .models import (
DeviceBay, DeviceBayTemplate, CONNECTION_STATUS_CHOICES, CONNECTION_STATUS_PLANNED, CONNECTION_STATUS_CONNECTED,
ConsolePort, ConsolePortTemplate, ConsoleServerPort, ConsoleServerPortTemplate, Device, DeviceRole, DeviceType,
Expand Down
Loading